added tests for QueryAPI and changed a slight bug in the switch method of QueryAPI