Tests were failing randomly because the order of the results varied.

The keys of the internal map are now sorted and ranged in order to give
a consistently ordered response that we can assert against.