fixes #68 - use mocha and fix a whole lotta bugs.

thanks to @jonanh for finding the first bug and kickstarting this whole process.