Fixed a bug when reading collections containing structs,  and added a bunch of tests.