moved writing to archive into function, added test for xml output