Added tests and fixed bugs for async support