Finished passing Jasmine tests
refactored