Tests rewritten in mocha/chai

As a nice side-effect, this also fixes the build.