fix bugs in mocha unit tests