Unit testing with karma
Fixed a couple of bugs while testing