added tests for the optional query interface

mea culpa for issuing a PR without tests in the first place