DRYout frontend code and add some tests

* Add Karma config and necessary packages for unit testing in Angular.
* The build directory is ignored, but after karma is run the it contains coverage and unit test reports.
* Replace many underscore calls with their Angular equivalents.
* Fix various code style issues