Fix tests with Perl 5.18

Some hashes started to return keys in randomized order. Sorting
said keys may impose a performance penalty, but it allows the tests
to stay (mostly) as is.