Improve session caching behaviour in MongoDB.

* Should more closely match hibernate.
* Cached version is now always used if available, even in query results.
* Improved getAll method to return any available cached entities and
  only query for missing entities.
* Added test cases to check behaviour in Mongo.