Add a test for same-thread asynchronous exceptions (see #1779233).