add jasmine and unit tests, fix some bugs