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.
WIP replace query cache
Fix levels cache
Replace the cache features of query by the dedicated query.cache.

This is WIP
Add isolation to state tests.