Added a test case where  comes first and attributes are ignored. Fixed the issue by pre-sorting the object keys.