Refactor otest-query

* OTestQuery.m refactored to reduce duplicate code
* OtestQuery.m has better exit codes and error messages
* otest-query's main.m has better error messages when given the wrong number of args