refactor email tests