Improve email parsing with tests