test: Refactor a repeated query expectation into a helper method.