fixed XML handling, added more complete tests