refactor js to pass dependencies to buildMapFor method. Added jasmine tests