Added KeySorter to serialization, some more tests.
Variables are serialized in a different order, so tests fail but XMLs
are similar.