Serialize tag attributes in a stable order

`attributes.iteritems()` doesn't have a guaranteed order and depends on the underlying implementation.
This caused some tests to fail under specific circumstances because they were expecting a specific order which wasn't the one returned in this case.

This fix makes attributes serialization stable, and fix some tests which were expecting a different order than the new, stable, one.

This is a proposed fix for #50, it seems to be sufficient but it's open for comment.