unit test the Query Builder

With a couple of missing tests though..