refactor to use function for err, success

- add unit tests for sms and email