Added Karma/Jasmine tests and some minor modifications in script