Refactor with mocha