Adding jasmine tests; code cleanup.