diff --git a/smash/web/tests/functions.py b/smash/web/tests/functions.py
index 7f158d8b08e6fac59f6b29646504d00fe1efff64..f283c978566d37d192a95de77b2bfd1ae050c917 100644
--- a/smash/web/tests/functions.py
+++ b/smash/web/tests/functions.py
@@ -389,7 +389,7 @@ def prepare_test_redcap_connection():
     token_item = ConfigurationItem.objects.filter(
         type=REDCAP_TOKEN_CONFIGURATION_TYPE)[0]
     # noinspection SpellCheckingInspection
-    token_item.value = "5C75EEC3DBDDA5218B6ACC0424B3F695"
+    token_item.value = "5DC21D45E3A2E068659F11046EA88734"
     token_item.save()
     url_item = ConfigurationItem.objects.filter(
         type=REDCAP_BASE_URL_CONFIGURATION_TYPE)[0]
diff --git a/smash/web/tests/test_RedcapConnector.py b/smash/web/tests/test_RedcapConnector.py
index 0841fbfd4c2135ee9846a0cac8743ea1691a3815..fb539c990c624524e56eddfb2d5aed7d3c693f74 100644
--- a/smash/web/tests/test_RedcapConnector.py
+++ b/smash/web/tests/test_RedcapConnector.py
@@ -53,7 +53,7 @@ class TestRedcapConnector(TestCase):
         prepare_test_redcap_connection()
         subject = create_study_subject()
         # noinspection SpellCheckingInspection
-        subject.nd_number = 'NDtest_external'
+        subject.nd_number = 'test_3'
         subject.save()
 
         redcap_connection = RedcapConnector()
@@ -207,7 +207,7 @@ class TestRedcapConnector(TestCase):
         prepare_test_redcap_connection()
         subject = create_study_subject()
         # noinspection SpellCheckingInspection
-        subject.nd_number = 'NDtest_external'
+        subject.nd_number = 'test_3'
         subject.save()
 
         redcap_connection = RedcapConnector()
diff --git a/smash/web/views/mails.py b/smash/web/views/mails.py
index b0ac390715edff01ea3e41d2f69f3d0d762593ef..ef4cf0b3bb6ce05c8ff4f35b0246c0f830ea5171 100644
--- a/smash/web/views/mails.py
+++ b/smash/web/views/mails.py
@@ -4,23 +4,19 @@ from wsgiref.util import FileWrapper
 
 from django.contrib import messages
 from django.http import HttpResponse
-from django.shortcuts import get_object_or_404
+from django.shortcuts import redirect, get_object_or_404
 from django.urls import reverse_lazy
-from django.views.generic import CreateView
 from django.views.generic import DeleteView
 from django.views.generic import ListView
-from django.views.generic import UpdateView
 
 from web.docx_helper import merge_files
 from . import WrappedView
+from . import wrap_response
+from ..forms.mail_template import MailTemplateForm
 from ..models import StudySubject, Visit, Appointment, MailTemplate, Voucher
 from ..models.constants import MAIL_TEMPLATE_CONTEXT_SUBJECT, MAIL_TEMPLATE_CONTEXT_VISIT, \
     MAIL_TEMPLATE_CONTEXT_APPOINTMENT, MAIL_TEMPLATE_CONTEXT_VOUCHER
 
-from ..forms.mail_template import MailTemplateForm
-from . import wrap_response
-from django.shortcuts import redirect, get_object_or_404
-
 MIMETYPE_DOCX = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
 
 CONTEXT_TYPES_MAPPING = {
@@ -46,29 +42,41 @@ class MailTemplatesListView(ListView, WrappedView):
                                    }
         return context
 
+
 def mail_template_add(request):
     if request.method == 'POST':
         form = MailTemplateForm(request.POST, request.FILES)
         if form.is_valid():
-            form.save()
+            try:
+                form.save()
+            except:
+                messages.add_message(request, messages.ERROR, 'There was a problem when saving template. '
+                                                              'Contact system administrator.')
             return redirect('web.views.mail_templates')
     else:
         form = MailTemplateForm()
 
     return wrap_response(request, 'mail_templates/add.html', {'form': form})
 
+
 def mail_template_edit(request, pk):
     template = get_object_or_404(MailTemplate, pk=pk)
     if request.method == 'POST':
         form = MailTemplateForm(request.POST, request.FILES, instance=template)
         if form.is_valid():
-            form.save()
-            return redirect('web.views.mail_templates')
+            try:
+                form.save()
+                return redirect('web.views.mail_templates')
+            except:
+                messages.add_message(request, messages.ERROR, 'There was a problem when updating template. '
+                                                              'Contact system administrator.')
+                return wrap_response(request, 'mail_templates/edit.html', {'form': form, 'mail_template': template})
     else:
         form = MailTemplateForm(instance=template)
 
     return wrap_response(request, 'mail_templates/edit.html', {'form': form, 'mail_template': template})
 
+
 class MailTemplatesDeleteView(DeleteView, WrappedView):
     model = MailTemplate
     success_url = reverse_lazy('web.views.mail_templates')
@@ -76,7 +84,13 @@ class MailTemplatesDeleteView(DeleteView, WrappedView):
 
     def delete(self, request, *args, **kwargs):
         messages.success(request, "Template deleted")
-        return super(MailTemplatesDeleteView, self).delete(request, *args, **kwargs)
+        try:
+            return super(MailTemplatesDeleteView, self).delete(request, *args, **kwargs)
+        except:
+            messages.add_message(request, messages.ERROR, 'There was a problem when deleting template. '
+                                                          'Contact system administrator.')
+        return redirect('web.views.mail_templates')
+
 
 def generate(request, mail_template_id, instance_id):
     mail_template = get_object_or_404(MailTemplate, id=mail_template_id)
@@ -90,6 +104,7 @@ def generate(request, mail_template_id, instance_id):
     response['Content-Disposition'] = 'attachment; filename={}.docx'.format(mail_template.name)
     return response
 
+
 def generate_for_vouchers(request):
     ids = request.GET.get('voucher_id', '').split(',')
     vouchers = []