Added code to make this work with mocha-phantomjs
and also fixed a bug in getMessageBody