diff --git a/dirsrvtests/tests/suites/betxns/betxn_test.py b/dirsrvtests/tests/suites/betxns/betxn_test.py
index 3b814348d..024bb901f 100644
--- a/dirsrvtests/tests/suites/betxns/betxn_test.py
+++ b/dirsrvtests/tests/suites/betxns/betxn_test.py
@@ -7,22 +7,23 @@
 # --- END COPYRIGHT BLOCK ---
 #
 import pytest
-import six
 import ldap
 from lib389.tasks import *
 from lib389.utils import *
 from lib389.topologies import topology_st
-
-from lib389.plugins import SevenBitCheckPlugin, AttributeUniquenessPlugin, MemberOfPlugin
-
+from lib389.plugins import (SevenBitCheckPlugin, AttributeUniquenessPlugin,
+                            MemberOfPlugin, ManagedEntriesPlugin,
+                            ReferentialIntegrityPlugin, MEPTemplates,
+                            MEPConfigs)
 from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES
-from lib389.idm.group import Groups
-
-from lib389._constants import DEFAULT_SUFFIX, PLUGIN_7_BIT_CHECK, PLUGIN_ATTR_UNIQUENESS, PLUGIN_MEMBER_OF
+from lib389.idm.organizationalunit import OrganizationalUnits
+from lib389.idm.group import Groups, Group
+from lib389._constants import DEFAULT_SUFFIX
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
 
+
 def test_betxt_7bit(topology_st):
     """Test that the 7-bit plugin correctly rejects an invalid update
 
@@ -52,7 +53,6 @@ def test_betxt_7bit(topology_st):
     sevenbc.enable()
     topology_st.standalone.restart()
 
-
     users = UserAccounts(topology_st.standalone, basedn=DEFAULT_SUFFIX)
     user = users.create(properties=TEST_USER_PROPERTIES)
 
@@ -100,9 +100,6 @@ def test_betxn_attr_uniqueness(topology_st):
             5. Test user entry should be removed
     """
 
-    USER1_DN = 'uid=test_entry1,' + DEFAULT_SUFFIX
-    USER2_DN = 'uid=test_entry2,' + DEFAULT_SUFFIX
-
     attruniq = AttributeUniquenessPlugin(topology_st.standalone)
     attruniq.enable()
     topology_st.standalone.restart()
@@ -110,26 +107,26 @@ def test_betxn_attr_uniqueness(topology_st):
     users = UserAccounts(topology_st.standalone, basedn=DEFAULT_SUFFIX)
     user1 = users.create(properties={
         'uid': 'testuser1',
-        'cn' : 'testuser1',
-        'sn' : 'user1',
-        'uidNumber' : '1001',
-        'gidNumber' : '2001',
-        'homeDirectory' : '/home/testuser1'
+        'cn': 'testuser1',
+        'sn': 'user1',
+        'uidNumber': '1001',
+        'gidNumber': '2001',
+        'homeDirectory': '/home/testuser1'
     })
 
     try:
-        user2 = users.create(properties={
+        users.create(properties={
             'uid': ['testuser2', 'testuser1'],
-            'cn' : 'testuser2',
-            'sn' : 'user2',
-            'uidNumber' : '1002',
-            'gidNumber' : '2002',
-            'homeDirectory' : '/home/testuser2'
+            'cn': 'testuser2',
+            'sn': 'user2',
+            'uidNumber': '1002',
+            'gidNumber': '2002',
+            'homeDirectory': '/home/testuser2'
         })
         log.fatal('test_betxn_attr_uniqueness: The second entry was incorrectly added.')
         assert False
-    except ldap.LDAPError as e:
-        log.error('test_betxn_attr_uniqueness: Failed to add test user as expected:')
+    except ldap.LDAPError:
+        log.error('test_betxn_attr_uniqueness: Failed to add test user as expected')
 
     user1.delete()
 
@@ -192,7 +189,7 @@ def test_betxn_memberof(topology_st):
 
 
 def test_betxn_modrdn_memberof(topology_st):
-    """Test modrdn operartions and memberOf
+    """Test modrdn operations and memberOf
 
     :id: 70d0b96e-b693-4bf7-bbf5-102a66ac5994
 
@@ -247,6 +244,90 @@ def test_betxn_modrdn_memberof(topology_st):
     log.info('test_betxn_modrdn_memberof: PASSED')
 
 
+def test_ri_and_mep(topology_st):
+    """Test RI plugin aborts change after MEP plugin fails
+
+    :id: 70d0b96e-b693-4bf7-bbf5-102a66ac5994
+
+    :setup: Standalone instance
+
+    :steps: 1. Enable and configure memberOf plugin
+            2. Set memberofgroupattr="member" and memberofAutoAddOC="nsContainer"
+            3. Create group and user outside of memberOf plugin scope
+            4. Do modrdn to move group into scope
+            5. Do modrdn to move group into scope (again)
+
+    :expectedresults:
+    """
+    # Start plugins
+    topology_st.standalone.config.set('nsslapd-dynamic-plugins', 'on')
+    mep_plugin = ManagedEntriesPlugin(topology_st.standalone)
+    mep_plugin.enable()
+    ri_plugin = ReferentialIntegrityPlugin(topology_st.standalone)
+    ri_plugin.enable()
+    memberof_plugin = MemberOfPlugin(topology_st.standalone)
+    memberof_plugin.enable()
+
+    # Add our org units
+    ous = OrganizationalUnits(topology_st.standalone, DEFAULT_SUFFIX)
+    ou_people = ous.create(properties={'ou': 'managed_people'})
+    ou_groups = ous.create(properties={'ou': 'managed_groups'})
+
+    # Configure MEP
+    mep_templates = MEPTemplates(topology_st.standalone, DEFAULT_SUFFIX)
+    mep_template1 = mep_templates.create(properties={
+        'cn': 'MEP template',
+        'mepRDNAttr': 'cn',
+        'mepStaticAttr': 'objectclass: posixGroup|objectclass: extensibleObject'.split('|'),
+        'mepMappedAttr': 'cn: $cn|uid: $cn|gidNumber: $uidNumber'.split('|')
+    })
+    mep_configs = MEPConfigs(topology_st.standalone)
+    mep_configs.create(properties={'cn': 'config',
+                                                'originScope': ou_people.dn,
+                                                'originFilter': 'objectclass=posixAccount',
+                                                'managedBase': ou_groups.dn,
+                                                'managedTemplate': mep_template1.dn})
+
+    # Add an entry that meets the MEP scope
+    users = UserAccounts(topology_st.standalone, DEFAULT_SUFFIX,
+                         rdn='ou={}'.format(ou_people.rdn))
+    user = users.create_test_user(1001)
+
+    # Add group
+    groups = Groups(topology_st.standalone, DEFAULT_SUFFIX)
+    user_group = groups.create(properties={'cn': 'group', 'member': user.dn})
+
+    # Check if a managed group entry was created
+    mep_group = Group(topology_st.standalone, dn='cn={},{}'.format(user.rdn, ou_groups.dn))
+    if not mep_group.exists():
+        log.fatal("MEP group was not created for the user")
+        assert False
+
+    # Mess with MEP so it fails
+    mep_plugin.disable()
+    mep_group.delete()
+    mep_plugin.enable()
+
+    # Delete user, should fail, and user should still be a member
+    with pytest.raises(ldap.NO_SUCH_OBJECT):
+        user.delete()
+
+    # Verify membership is intact
+    if not user_group.is_member(user.dn):
+        log.fatal("Member was incorrectly removed from the group!!  Or so it seems")
+
+        # Restart server and test again in case this was a cache issue
+        topology_st.standalone.restart()
+        if user_group.is_member(user.dn):
+            log.info("The entry cache was corrupted")
+            assert False
+
+        assert False
+
+    # Success
+    log.info("Test PASSED")
+
+
 if __name__ == '__main__':
     # Run isolated
     # -s for DEBUG mode
diff --git a/dirsrvtests/tests/suites/plugins/acceptance_test.py b/dirsrvtests/tests/suites/plugins/acceptance_test.py
index 894c0ff25..f44b684ce 100644
--- a/dirsrvtests/tests/suites/plugins/acceptance_test.py
+++ b/dirsrvtests/tests/suites/plugins/acceptance_test.py
@@ -18,7 +18,7 @@ from lib389.utils import *
 from lib389.plugins import *
 from lib389._constants import *
 from lib389.dseldif import DSEldif
-from lib389.idm.user import UserAccounts, UserAccount
+from lib389.idm.user import UserAccounts
 from lib389.idm.group import Groups
 from lib389.idm.organizationalunit import OrganizationalUnits
 from lib389.idm.domain import Domain
