Move more query tests over to PHPUnit