refactored api
included Jasmine for testing
added tests & minor bug fixes