Added Query object and queryEntities + tests.