Added unit tests for query interface, which led to a bunch of fixes
Added createQuery() to record manager