Homogenization and dimension reduction of thin heterogeneous layers