Update query builder. Add tests.