Fix setting hooks in ApiQueryTest