Switch to Karma and Mocha for tests, rewrite tests