extract js + add jasmine tests