Added query validation functions, fleshed out tests

Addresses #35