Tests on QueryBuilder.  Pulling things out into an interface for testability