Fixed a bug in the xml serializer where the wrong collection was checked
to prevent a index out of bounds exception when multiple messages of the
same type was sent. Closes #899