Refactors Message Queue CLI module

Also fixes a bug in the message queue client.