generalized runQuery and getState, exposed some internals for extending Spock