refactored tests to works in node.js and the browser