Fix more test errors.
Convert email templates to Jinja2.