Pull request for issues

OK, this PR adds mocha testing and fixes #66. I will only push here if I'm sure it works, so feel free to merge it.