refactored for mocha tests