Fixed asynchronous errors and improving code quality and test coverage