refactoring and covering more jasmine tests