small modifications to make this work with browserify
shuffle and port tests to mocha