Moved the duplicate code for creating valid pending queries to a
test utility method