completely refactored into proper nodejs module, added jasmine unit tests