added Jasmine tests, and some minor bug fixes