Preserve state in query tests