move helpers to shared lib file to enable email sending to use the same set of helpers, fix email sending