Added 3D tests and ability to write grid