Refactor email tests