Added unit tests and node.js compatiblity