refactor the email sender into separate classes and add tests