Magnetic and structural investigations on NiI2 and CoI2