allow for complex queries with undefined query (select all), added tests