Fix tests and some leaks, use local version of mocha