Use Karma test runner to run tests

This changes the tests to be ran using the [Karma test runner](http://karma-runner.github.io/). This makes it easier to automatically run tests when a file changes, and also allows it to [run tests under Firefox and PhantomJS in Travis](http://karma-runner.github.io/0.8/plus/Travis-CI.html).