More unit tests for storage drivers and a bug fix for memory storage

This PR contains several unit tests. It also contains a bug fix for memory storage. The bug could be reproduced with the newly added unit tests in this PR.
That's a good point, my concern is what we expose in the REST API. If it should be sorted we should sort it in the manager (which should be able to). I don't think if this PR breaks the UI since it flips the order of the stats :)