Created jasmine tests and cleaned up bugs in code