Test exception handling