refactor functions to variables, using jquery and jasmine-ajax, fix earlier broken test