QueryGenerator unit tests + small bug fixes