Added mocha and first tests and fixes