Added unit test for exception handling in async and cleaned up some code