refs #2, gather email code, pull out test code, clean up