improve test coverage and resolve mocha async issues