unit test for the task that throws from CloseEvent handler

this is a branch off pull request #843