Changed the querying, which now works with unit tests