Added unit tests for cmd_query module

The code coverage for cmd_query.c is now 100%.

I also updaed validateAnnexIs() in cmd_query.c to properly handle the
pAnnex parameter being NULL.