factored out query utils
added variables data call
added test coverage, test suite