Fixed a bug in the reading method for xml and added a test.