Restructured emailclient module, and added unit tests for it.