Add first tests to query. Refactoring starts.
Extract cache component from query

The cache component is a sub-namespace of the query namespace.
This helps to get a better separation of code and a much clearer
interface of query.
This commit only extracts the cache from schema to the hierarchy.
The cache functions are not replaced in query yet.
Port the levels layer in query.cache.
Port the properties layer in query.cache.
Replace the cache features of query by the dedicated query.cache.
Add isolation to state tests.
Update query documentation
Set some query's methods as private
Add an helper function to query to avoid duplication.