fix query results; change error behavior to return state from Databasedotcom; add tests for query results