Improve testing for email error cases