improved testing infrastructure, query building improvements, and partial unit testing on hooks