'use strict';
angular.module('lemur')
  .service('NotificationApi', function (LemurRestangular) {
    LemurRestangular.extendModel('notifications', function (obj) {
      return angular.extend(obj, {
        attachCertificate: function (certificate) {
          this.selectedCertificate = null;
          if (this.certificates === undefined) {
            this.certificates = [];
          }
          if (this.addedCertificates === undefined) {
            this.addedCertificates = [];
          }
          this.certificates.push(certificate);
          this.addedCertificates.push(certificate);
          if (this.removedCertificates !== undefined) {
            const index = this.removedCertificates.indexOf(certificate);
            if (index > -1) {
              this.removedCertificates.splice(index, 1);
            }
          }
        },
        removeCertificate: function (index) {
          if (this.removedCertificates === undefined) {
            this.removedCertificates = [];
          }
          const removedCert = this.certificates.splice(index, 1);
          this.removedCertificates.push(removedCert);
          if (this.addedCertificates !== undefined && this.addedCertificates.indexOf(removedCert) > -1) {
            this.addedCertificates.splice(this.addedCertificates.indexOf(removedCert), 1);
          }
        }
      });
    });
    return LemurRestangular.all('notifications');
  })
  .service('NotificationService', function ($location,  NotificationApi, PluginService) {
    var NotificationService = this;
    NotificationService.findNotificationsByName = function (filterValue) {
      return NotificationApi.getList({'filter[label]': filterValue})
        .then(function (notifications) {
          return notifications;
        });
    };

    NotificationService.getCertificates = function (notification) {
      notification.getList('certificates', {showExpired: 0}).then(function (certificates) {
        notification.certificates = certificates;
      });
    };

    NotificationService.getPlugin = function (notification) {
      return PluginService.getByName(notification.pluginName).then(function (plugin) {
        notification.plugin = plugin;
      });
    };


    NotificationService.loadMoreCertificates = function (notification, page) {
      notification.getList('certificates', {page: page, showExpired: 0}).then(function (certificates) {
        _.each(certificates, function (certificate) {
          notification.roles.push(certificate);
        });
      });
    };

    NotificationService.create = function (notification) {
      return NotificationApi.post(notification);
    };

    NotificationService.update = function (notification) {
      this.certificates = [];
      return notification.put();
    };

    NotificationService.updateActive = function (notification) {
      notification.put();
    };
    return NotificationService;
  });

@@ -665,17 +665,24 @@
   const 
-i
+removedI
 ndex = t
@@ -743,17 +743,24 @@
     if (
-i
+removedI
 ndex %3E -
@@ -802,33 +802,40 @@
 ificates.splice(
-i
+removedI
 ndex, 1);%0A      
@@ -1196,11 +1196,42 @@
 ined
- &&
+) %7B%0A            const addedIndex =
  thi
@@ -1270,16 +1270,44 @@
 vedCert)
+;%0A            if (addedIndex
  %3E -1) %7B
@@ -1299,32 +1299,34 @@
 edIndex %3E -1) %7B%0A
+  
             this
@@ -1355,56 +1355,37 @@
 ice(
-this.addedCertificates.indexOf(removedCert), 1);
+addedIndex, 1);%0A            %7D
 %0A   

Make code more parallel