From c0a80d282aed7d170d7449956bde6f4e06715daa Mon Sep 17 00:00:00 2001
From: Akshay Adhikari <aadhikar@redhat.com>
Date: Jul 02 2018 14:21:38 +0000
Subject: Issue 49588 - Add py3 support for tickets : part-3


Description: Added py3 support by explicitly changing strings to bytes.

https://pagure.io/389-ds-base/issue/49588

Reviewed by: vashirov (Thanks!)

---

diff --git a/dirsrvtests/tests/tickets/ticket47560_test.py b/dirsrvtests/tests/tickets/ticket47560_test.py
index 175b712..273f944 100644
--- a/dirsrvtests/tests/tickets/ticket47560_test.py
+++ b/dirsrvtests/tests/tickets/ticket47560_test.py
@@ -15,6 +15,7 @@ from lib389 import Entry
 from lib389._constants import *
 from lib389.properties import *
 from lib389.topologies import topology_st
+from lib389.utils import *
 
 log = logging.getLogger(__name__)
 
@@ -95,7 +96,7 @@ def test_ticket47560(topology_st):
         except ldap.ALREADY_EXISTS:
             log.debug("Entry %s already exists" % (member_DN))
 
-        replace = [(ldap.MOD_REPLACE, 'memberof', group_DN)]
+        replace = [(ldap.MOD_REPLACE, 'memberof', ensure_bytes(group_DN))]
         topology_st.standalone.modify_s(member_DN, replace)
 
         #
@@ -111,7 +112,7 @@ def test_ticket47560(topology_st):
         assert len(ents) == 1
         ent = ents[0]
         # print ent
-        value = ent.getValue('memberof')
+        value = ensure_str(ent.getValue('memberof'))
         # print "memberof: %s" % (value)
         assert value == group_DN
 
@@ -165,7 +166,7 @@ def test_ticket47560(topology_st):
     ent = ents[0]
     log.debug("Fixed entry %r\n" % ent)
 
-    if ent.getValue('memberof') == group_DN:
+    if ensure_str(ent.getValue('memberof')) == group_DN:
         log.warning("Error the fixupMemberOf did not fix %s" % (member_DN))
         result_successful = False
     else:
diff --git a/dirsrvtests/tests/tickets/ticket47573_test.py b/dirsrvtests/tests/tickets/ticket47573_test.py
index 1b443ef..5019ec1 100644
--- a/dirsrvtests/tests/tickets/ticket47573_test.py
+++ b/dirsrvtests/tests/tickets/ticket47573_test.py
@@ -20,6 +20,7 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_m1c1
+from lib389.utils import *
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
@@ -68,7 +69,7 @@ def _oc_definition(oid_ext, name, must=None, may=None):
         may = MAY_OLD
 
     new_oc = "( %s  NAME '%s' DESC '%s' SUP %s AUXILIARY MUST %s MAY %s )" % (oid, name, desc, sup, must, may)
-    return new_oc
+    return ensure_bytes(new_oc)
 
 
 def add_OC(instance, oid_ext, name):
@@ -92,7 +93,7 @@ def trigger_schema_push(topology_m1c1):
         trigger_schema_push.value += 1
     except AttributeError:
         trigger_schema_push.value = 1
-    replace = [(ldap.MOD_REPLACE, 'telephonenumber', str(trigger_schema_push.value))]
+    replace = [(ldap.MOD_REPLACE, 'telephonenumber', ensure_bytes(str(trigger_schema_push.value)))]
     topology_m1c1.ms["master1"].modify_s(ENTRY_DN, replace)
 
     # wait 10 seconds that the update is replicated
diff --git a/dirsrvtests/tests/tickets/ticket47640_test.py b/dirsrvtests/tests/tickets/ticket47640_test.py
index 3a9f13c..833f9fb 100644
--- a/dirsrvtests/tests/tickets/ticket47640_test.py
+++ b/dirsrvtests/tests/tickets/ticket47640_test.py
@@ -28,7 +28,7 @@ def test_ticket47640(topology_st):
 
     # Enable Dynamic plugins, and the linked Attrs plugin
     try:
-        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', 'on')])
+        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'on')])
     except ldap.LDAPError as e:
         log.fatal('Failed to enable dynamic plugin!' + e.message['desc'])
         assert False
diff --git a/dirsrvtests/tests/tickets/ticket47653MMR_test.py b/dirsrvtests/tests/tickets/ticket47653MMR_test.py
index 6f6a5d4..c23a345 100644
--- a/dirsrvtests/tests/tickets/ticket47653MMR_test.py
+++ b/dirsrvtests/tests/tickets/ticket47653MMR_test.py
@@ -56,7 +56,7 @@ def _oc_definition(oid_ext, name, must=None, may=None):
         may = MAY
 
     new_oc = "( %s  NAME '%s' DESC '%s' SUP %s AUXILIARY MUST %s MAY %s )" % (oid, name, desc, sup, must, may)
-    return new_oc
+    return ensure_bytes(new_oc)
 
 
 def test_ticket47653_init(topology_m2):
@@ -82,7 +82,7 @@ def test_ticket47653_init(topology_m2):
 
     if DEBUGGING:
         # enable acl error logging
-        mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', str(128 + 8192))]  # ACL + REPL
+        mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', ensure_bytes(str(128 + 8192)))]  # ACL + REPL
         topology_m2.ms["master1"].modify_s(DN_CONFIG, mod)
         topology_m2.ms["master2"].modify_s(DN_CONFIG, mod)
 
@@ -159,7 +159,7 @@ def test_ticket47653_add(topology_m2):
     ACI_ALLOW = "(version 3.0; acl \"SelfDN add\"; allow (add)"
     ACI_SUBJECT = " userattr = \"member#selfDN\";)"
     ACI_BODY = ACI_TARGET + ACI_TARGETFILTER + ACI_ALLOW + ACI_SUBJECT
-    mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
+    mod = [(ldap.MOD_ADD, 'aci', ensure_bytes(ACI_BODY))]
     topology_m2.ms["master1"].modify_s(SUFFIX, mod)
     time.sleep(1)
 
@@ -215,7 +215,7 @@ def test_ticket47653_add(topology_m2):
 
     # Now update the entry on Master2 (as DM because 47653 is possibly not fixed on M2)
     topology_m2.ms["master1"].log.info("Update  %s on M2" % ENTRY_DN)
-    mod = [(ldap.MOD_REPLACE, 'description', 'test_add')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'test_add')]
     topology_m2.ms["master2"].modify_s(ENTRY_DN, mod)
     time.sleep(1)
 
@@ -224,13 +224,13 @@ def test_ticket47653_add(topology_m2):
     while loop <= 10:
         try:
             ent = topology_m2.ms["master1"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
-            if ent.hasAttr('description') and (ent.getValue('description') == 'test_add'):
+            if ent.hasAttr('description') and (ensure_str(ent.getValue('description')) == 'test_add'):
                 break
         except ldap.NO_SUCH_OBJECT:
             time.sleep(1)
             loop += 1
 
-    assert ent.getValue('description') == 'test_add'
+    assert ensure_str(ent.getValue('description')) == 'test_add'
 
 
 def test_ticket47653_modify(topology_m2):
@@ -252,7 +252,7 @@ def test_ticket47653_modify(topology_m2):
     # entry to modify WITH member being BIND_DN but WITHOUT the ACI -> ldap.INSUFFICIENT_ACCESS
     try:
         topology_m2.ms["master1"].log.info("Try to modify  %s (aci is missing)" % ENTRY_DN)
-        mod = [(ldap.MOD_REPLACE, 'postalCode', '9876')]
+        mod = [(ldap.MOD_REPLACE, 'postalCode', b'9876')]
         topology_m2.ms["master1"].modify_s(ENTRY_DN, mod)
     except Exception as e:
         topology_m2.ms["master1"].log.info("Exception (expected): %s" % type(e).__name__)
@@ -268,7 +268,7 @@ def test_ticket47653_modify(topology_m2):
     ACI_ALLOW = "(version 3.0; acl \"SelfDN write\"; allow (write)"
     ACI_SUBJECT = " userattr = \"member#selfDN\";)"
     ACI_BODY = ACI_TARGET + ACI_TARGETATTR + ACI_TARGETFILTER + ACI_ALLOW + ACI_SUBJECT
-    mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
+    mod = [(ldap.MOD_ADD, 'aci', ensure_bytes(ACI_BODY))]
     topology_m2.ms["master1"].modify_s(SUFFIX, mod)
     time.sleep(2)
 
@@ -279,7 +279,7 @@ def test_ticket47653_modify(topology_m2):
 
     # modify the entry and checks the value
     topology_m2.ms["master1"].log.info("M1: Try to modify  %s. It should succeeds" % ENTRY_DN)
-    mod = [(ldap.MOD_REPLACE, 'postalCode', '1928')]
+    mod = [(ldap.MOD_REPLACE, 'postalCode', b'1928')]
     topology_m2.ms["master1"].modify_s(ENTRY_DN, mod)
 
     topology_m2.ms["master1"].log.info("M1: Bind as %s" % DN_DM)
@@ -288,7 +288,7 @@ def test_ticket47653_modify(topology_m2):
     topology_m2.ms["master1"].log.info("M1: Check the update of %s" % ENTRY_DN)
     ents = topology_m2.ms["master1"].search_s(ENTRY_DN, ldap.SCOPE_BASE, 'objectclass=*')
     assert len(ents) == 1
-    assert ents[0].postalCode == '1928'
+    assert ensure_str(ents[0].postalCode) == '1928'
 
     # Now check the update has been replicated on M2
     topology_m2.ms["master1"].log.info("M2: Bind as %s" % DN_DM)
@@ -298,13 +298,13 @@ def test_ticket47653_modify(topology_m2):
     while loop <= 10:
         try:
             ent = topology_m2.ms["master2"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
-            if ent.hasAttr('postalCode') and (ent.getValue('postalCode') == '1928'):
+            if ent.hasAttr('postalCode') and (ensure_str(ent.getValue('postalCode')) == '1928'):
                 break
         except ldap.NO_SUCH_OBJECT:
             time.sleep(1)
             loop += 1
     assert loop <= 10
-    assert ent.getValue('postalCode') == '1928'
+    assert ensure_str(ent.getValue('postalCode')) == '1928'
 
     # Now update the entry on Master2 bound as BIND_DN (update may fail if  47653 is  not fixed on M2)
     topology_m2.ms["master1"].log.info("M2: Update  %s (bound as %s)" % (ENTRY_DN, BIND_DN))
@@ -312,7 +312,7 @@ def test_ticket47653_modify(topology_m2):
     time.sleep(1)
     fail = False
     try:
-        mod = [(ldap.MOD_REPLACE, 'postalCode', '1929')]
+        mod = [(ldap.MOD_REPLACE, 'postalCode', b'1929')]
         topology_m2.ms["master2"].modify_s(ENTRY_DN, mod)
         fail = False
     except ldap.INSUFFICIENT_ACCESS:
@@ -332,12 +332,12 @@ def test_ticket47653_modify(topology_m2):
         while loop <= 10:
             try:
                 ent = topology_m2.ms["master1"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
-                if ent.hasAttr('postalCode') and (ent.getValue('postalCode') == '1929'):
+                if ent.hasAttr('postalCode') and (ensure_str(ent.getValue('postalCode')) == '1929'):
                     break
             except ldap.NO_SUCH_OBJECT:
                 time.sleep(1)
                 loop += 1
-        assert ent.getValue('postalCode') == '1929'
+        assert ensure_str(ent.getValue('postalCode')) == '1929'
 
 
 if __name__ == '__main__':
diff --git a/dirsrvtests/tests/tickets/ticket47676_test.py b/dirsrvtests/tests/tickets/ticket47676_test.py
index 3468b90..fd6276b 100644
--- a/dirsrvtests/tests/tickets/ticket47676_test.py
+++ b/dirsrvtests/tests/tickets/ticket47676_test.py
@@ -19,6 +19,7 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_m2
+from lib389.replica import ReplicationManager
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 from lib389.utils import *
@@ -66,8 +67,13 @@ def _oc_definition(oid_ext, name, must=None, may=None):
         may = MAY
 
     new_oc = "( %s  NAME '%s' DESC '%s' SUP %s AUXILIARY MUST %s MAY %s )" % (oid, name, desc, sup, must, may)
-    return new_oc
+    return ensure_bytes(new_oc)
 
+def replication_check(topology_m2):
+    repl = ReplicationManager(SUFFIX)
+    master1 = topology_m2.ms["master1"]
+    master2 = topology_m2.ms["master2"]
+    return repl.test_replication(master1, master2)
 
 def test_ticket47676_init(topology_m2):
     """
@@ -91,7 +97,7 @@ def test_ticket47676_init(topology_m2):
         'userpassword': BIND_PW})))
 
     # enable acl error logging
-    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', str(128 + 8192))]  # ACL + REPL
+    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', ensure_bytes(str(128 + 8192)))]  # ACL + REPL
     topology_m2.ms["master1"].modify_s(DN_CONFIG, mod)
     topology_m2.ms["master2"].modify_s(DN_CONFIG, mod)
 
@@ -138,31 +144,18 @@ def test_ticket47676_skip_oc_at(topology_m2):
     #
     topology_m2.ms["master2"].simple_bind_s(DN_DM, PASSWORD)
     topology_m2.ms["master1"].log.info("Try to retrieve %s from Master2" % ENTRY_DN)
-    loop = 0
-    while loop <= 10:
-        try:
-            ent = topology_m2.ms["master2"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
-            break
-        except ldap.NO_SUCH_OBJECT:
-            time.sleep(2)
-            loop += 1
-    assert loop <= 10
-
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ent
     # Now update the entry on Master2 (as DM because 47676 is possibly not fixed on M2)
     topology_m2.ms["master1"].log.info("Update  %s on M2" % ENTRY_DN)
-    mod = [(ldap.MOD_REPLACE, 'description', 'test_add')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'test_add')]
     topology_m2.ms["master2"].modify_s(ENTRY_DN, mod)
 
     topology_m2.ms["master1"].simple_bind_s(DN_DM, PASSWORD)
-    loop = 0
-    while loop <= 10:
-        ent = topology_m2.ms["master1"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
-        if ent.hasAttr('description') and (ent.getValue('description') == 'test_add'):
-            break
-        time.sleep(1)
-        loop += 1
-
-    assert ent.getValue('description') == 'test_add'
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master1"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ensure_str(ent.getValue('description')) == 'test_add'
 
 
 def test_ticket47676_reject_action(topology_m2):
@@ -172,7 +165,7 @@ def test_ticket47676_reject_action(topology_m2):
     topology_m2.ms["master2"].simple_bind_s(DN_DM, PASSWORD)
 
     # make master1 to refuse to push the schema if OC_NAME is present in consumer schema
-    mod = [(ldap.MOD_ADD, 'schemaUpdateObjectclassReject', '%s' % (OC_NAME))]  # ACL + REPL
+    mod = [(ldap.MOD_ADD, 'schemaUpdateObjectclassReject', ensure_bytes('%s' % (OC_NAME)))]  # ACL + REPL
     topology_m2.ms["master1"].modify_s(REPL_SCHEMA_POLICY_SUPPLIER, mod)
 
     # Restart is required to take into account that policy
@@ -197,20 +190,15 @@ def test_ticket47676_reject_action(topology_m2):
 
     # Do an update of M1 so that M1 will try to push the schema
     topology_m2.ms["master1"].log.info("Update  %s on M1" % ENTRY_DN)
-    mod = [(ldap.MOD_REPLACE, 'description', 'test_reject')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'test_reject')]
     topology_m2.ms["master1"].modify_s(ENTRY_DN, mod)
 
     # Check the replication occured and so also M1 attempted to push the schema
     topology_m2.ms["master1"].log.info("Check updated %s on M2" % ENTRY_DN)
-    loop = 0
-    while loop <= 10:
-        ent = topology_m2.ms["master2"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)", ['description'])
-        if ent.hasAttr('description') and ent.getValue('description') == 'test_reject':
-            # update was replicated
-            break
-        time.sleep(2)
-        loop += 1
-    assert loop <= 10
+
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)", ['description'])
+    assert ensure_str(ent.getValue('description')) == 'test_reject'
 
     # Check that the schema has not been pushed
     topology_m2.ms["master1"].log.info("Check %s is not in M2" % OC2_NAME)
@@ -226,7 +214,7 @@ def test_ticket47676_reject_action(topology_m2):
     topology_m2.ms["master1"].log.info("\n\n######################### NO MORE REJECT ACTION ######################\n")
 
     # make master1 to do no specific action on OC_NAME
-    mod = [(ldap.MOD_DELETE, 'schemaUpdateObjectclassReject', '%s' % (OC_NAME))]  # ACL + REPL
+    mod = [(ldap.MOD_DELETE, 'schemaUpdateObjectclassReject', ensure_bytes('%s' % (OC_NAME)))]  # ACL + REPL
     topology_m2.ms["master1"].modify_s(REPL_SCHEMA_POLICY_SUPPLIER, mod)
 
     # Restart is required to take into account that policy
@@ -235,21 +223,15 @@ def test_ticket47676_reject_action(topology_m2):
 
     # Do an update of M1 so that M1 will try to push the schema
     topology_m2.ms["master1"].log.info("Update  %s on M1" % ENTRY_DN)
-    mod = [(ldap.MOD_REPLACE, 'description', 'test_no_more_reject')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'test_no_more_reject')]
     topology_m2.ms["master1"].modify_s(ENTRY_DN, mod)
 
     # Check the replication occured and so also M1 attempted to push the schema
     topology_m2.ms["master1"].log.info("Check updated %s on M2" % ENTRY_DN)
-    loop = 0
-    while loop <= 10:
-        ent = topology_m2.ms["master2"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)", ['description'])
-        if ent.hasAttr('description') and ent.getValue('description') == 'test_no_more_reject':
-            # update was replicated
-            break
-        time.sleep(2)
-        loop += 1
-    assert loop <= 10
 
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)", ['description'])
+    assert ensure_str(ent.getValue('description')) == 'test_no_more_reject'
     # Check that the schema has been pushed
     topology_m2.ms["master1"].log.info("Check %s is in M2" % OC2_NAME)
     ent = topology_m2.ms["master2"].getEntry(SCHEMA_DN, ldap.SCOPE_BASE, "(objectclass=*)", ["objectclasses"])
diff --git a/dirsrvtests/tests/tickets/ticket47714_test.py b/dirsrvtests/tests/tickets/ticket47714_test.py
index 5ef9f9d..9e931e8 100644
--- a/dirsrvtests/tests/tickets/ticket47714_test.py
+++ b/dirsrvtests/tests/tickets/ticket47714_test.py
@@ -80,12 +80,12 @@ def test_ticket47714_run_0(topology_st):
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
 
     # Modify Account Policy config entry
-    topology_st.standalone.modify_s(ACCT_POLICY_CONFIG_DN, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', 'yes'),
-                                                            (ldap.MOD_REPLACE, 'stateattrname', 'lastLoginTime'),
-                                                            (ldap.MOD_REPLACE, 'altstateattrname', 'createTimestamp'),
-                                                            (ldap.MOD_REPLACE, 'specattrname', 'acctPolicySubentry'),
+    topology_st.standalone.modify_s(ACCT_POLICY_CONFIG_DN, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', b'yes'),
+                                                            (ldap.MOD_REPLACE, 'stateattrname', b'lastLoginTime'),
+                                                            (ldap.MOD_REPLACE, 'altstateattrname', b'createTimestamp'),
+                                                            (ldap.MOD_REPLACE, 'specattrname', b'acctPolicySubentry'),
                                                             (ldap.MOD_REPLACE, 'limitattrname',
-                                                             'accountInactivityLimit')])
+                                                             b'accountInactivityLimit')])
 
     # Enable the plugins
     topology_st.standalone.plugins.enable(name=PLUGIN_ACCT_POLICY)
@@ -96,7 +96,7 @@ def test_ticket47714_run_0(topology_st):
     try:
         topology_st.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW)
     except ldap.CONSTRAINT_VIOLATION as e:
-        log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+        log.error('CONSTRAINT VIOLATION {}'.format(e.args[0]['desc']))
 
     time.sleep(2)
 
@@ -109,7 +109,7 @@ def test_ticket47714_run_0(topology_st):
     try:
         topology_st.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW)
     except ldap.CONSTRAINT_VIOLATION as e:
-        log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+        log.error('CONSTRAINT VIOLATION {}'.format(e.args[0]['desc']))
 
     time.sleep(2)
 
@@ -125,7 +125,7 @@ def test_ticket47714_run_0(topology_st):
 
     # Now, change the inactivity limit, because that should trigger the account to now be locked. This is possible because the check is "delayed" until the usage of the account.
 
-    topology_st.standalone.modify_s(ACCT_POLICY_DN, [(ldap.MOD_REPLACE, 'accountInactivityLimit', '1'),])
+    topology_st.standalone.modify_s(ACCT_POLICY_DN, [(ldap.MOD_REPLACE, 'accountInactivityLimit', b'1'),])
     time.sleep(2)
 
     entry = topology_st.standalone.search_s(ACCT_POLICY_DN, ldap.SCOPE_BASE, SEARCHFILTER)
@@ -137,13 +137,13 @@ def test_ticket47714_run_0(topology_st):
     try:
         topology_st.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW)
     except ldap.CONSTRAINT_VIOLATION as e:
-        log.info('CONSTRAINT VIOLATION ' + e.message['desc'])
+        log.info('CONSTRAINT VIOLATION {}'.format(e.args[0]['desc']))
         log.info("%s was successfully inactivated." % TEST_USER_DN)
         pass
 
     # Now reset the value high to prevent issues with the next test.
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ACCT_POLICY_DN, [(ldap.MOD_REPLACE, 'accountInactivityLimit', INACTIVITY_LIMIT),])
+    topology_st.standalone.modify_s(ACCT_POLICY_DN, [(ldap.MOD_REPLACE, 'accountInactivityLimit', ensure_bytes(INACTIVITY_LIMIT)),])
 
 
 def test_ticket47714_run_1(topology_st):
@@ -161,14 +161,14 @@ def test_ticket47714_run_1(topology_st):
     topology_st.standalone.modify_s(TEST_USER_DN, [(ldap.MOD_DELETE, 'lastLoginTime', None)])
 
     # Modify Account Policy config entry
-    topology_st.standalone.modify_s(ACCT_POLICY_CONFIG_DN, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', 'yes'),
-                                                            (ldap.MOD_REPLACE, 'stateattrname', 'bogus'),
-                                                            (ldap.MOD_REPLACE, 'altstateattrname', 'modifyTimestamp'),
+    topology_st.standalone.modify_s(ACCT_POLICY_CONFIG_DN, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', b'yes'),
+                                                            (ldap.MOD_REPLACE, 'stateattrname', b'bogus'),
+                                                            (ldap.MOD_REPLACE, 'altstateattrname', b'modifyTimestamp'),
                                                             (
-                                                            ldap.MOD_REPLACE, 'alwaysRecordLoginAttr', 'lastLoginTime'),
-                                                            (ldap.MOD_REPLACE, 'specattrname', 'acctPolicySubentry'),
+                                                            ldap.MOD_REPLACE, 'alwaysRecordLoginAttr', b'lastLoginTime'),
+                                                            (ldap.MOD_REPLACE, 'specattrname', b'acctPolicySubentry'),
                                                             (ldap.MOD_REPLACE, 'limitattrname',
-                                                             'accountInactivityLimit')])
+                                                             b'accountInactivityLimit')])
 
     # Enable the plugins
     topology_st.standalone.plugins.enable(name=PLUGIN_ACCT_POLICY)
@@ -179,7 +179,7 @@ def test_ticket47714_run_1(topology_st):
     try:
         topology_st.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW)
     except ldap.CONSTRAINT_VIOLATION as e:
-        log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+        log.error('CONSTRAINT VIOLATION {}'.format(e.args[0]['desc']))
 
     time.sleep(1)
 
@@ -191,7 +191,7 @@ def test_ticket47714_run_1(topology_st):
     try:
         topology_st.standalone.simple_bind_s(TEST_USER_DN, TEST_USER_PW)
     except ldap.CONSTRAINT_VIOLATION as e:
-        log.error('CONSTRAINT VIOLATION ' + e.message['desc'])
+        log.error('CONSTRAINT VIOLATION {}'.format(e.args[0]['desc']))
 
     time.sleep(1)
 
diff --git a/dirsrvtests/tests/tickets/ticket47721_test.py b/dirsrvtests/tests/tickets/ticket47721_test.py
index db2ac61..ef57557 100644
--- a/dirsrvtests/tests/tickets/ticket47721_test.py
+++ b/dirsrvtests/tests/tickets/ticket47721_test.py
@@ -19,6 +19,8 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_m2
+from lib389.replica import ReplicationManager
+from lib389.utils import *
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
@@ -57,24 +59,29 @@ SLEEP_INTERVAL = 60
 def _add_custom_at_definition(name='ATticket47721'):
     new_at = "( %s-oid NAME '%s' DESC 'test AT ticket 47721' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN ( 'Test 47721' 'user defined' ) )" % (
     name, name)
-    return new_at
+    return ensure_bytes(new_at)
 
 
 def _chg_std_at_defintion():
     new_at = "( 2.16.840.1.113730.3.1.569 NAME 'cosPriority' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 X-ORIGIN 'Netscape Directory Server' )"
-    return new_at
+    return ensure_bytes(new_at)
 
 
 def _add_custom_oc_defintion(name='OCticket47721'):
     new_oc = "( %s-oid NAME '%s' DESC 'An group of related automount objects' SUP top STRUCTURAL MUST ou X-ORIGIN 'draft-howard-rfc2307bis' )" % (
     name, name)
-    return new_oc
+    return ensure_bytes(new_oc)
 
 
 def _chg_std_oc_defintion():
     new_oc = "( 5.3.6.1.1.1.2.0 NAME 'trustAccount' DESC 'Sets trust accounts information' SUP top AUXILIARY MUST trustModel MAY ( accessTo $ ou ) X-ORIGIN 'nss_ldap/pam_ldap' )"
-    return new_oc
+    return ensure_bytes(new_oc)
 
+def replication_check(topology_m2):
+    repl = ReplicationManager(SUFFIX)
+    master1 = topology_m2.ms["master1"]
+    master2 = topology_m2.ms["master2"]
+    return repl.test_replication(master1, master2)
 
 def test_ticket47721_init(topology_m2):
     """
@@ -94,7 +101,7 @@ def test_ticket47721_init(topology_m2):
         'userpassword': BIND_PW})))
 
     # enable repl error logging
-    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', str(8192))]  # REPL logging
+    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', ensure_bytes(str(8192)))]  # REPL logging
     topology_m2.ms["master1"].modify_s(DN_CONFIG, mod)
     topology_m2.ms["master2"].modify_s(DN_CONFIG, mod)
 
@@ -109,17 +116,9 @@ def test_ticket47721_init(topology_m2):
 
 def test_ticket47721_0(topology_m2):
     dn = "cn=%s0,%s" % (OTHER_NAME, SUFFIX)
-    loop = 0
-    ent = None
-    while loop <= 10:
-        try:
-            ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
-            break
-        except ldap.NO_SUCH_OBJECT:
-            time.sleep(1)
-            loop += 1
-    if ent is None:
-        assert False
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ent
 
 
 def test_ticket47721_1(topology_m2):
@@ -143,20 +142,13 @@ def test_ticket47721_1(topology_m2):
     topology_m2.ms["master1"].log.info("Chg (M2) %s " % new)
     topology_m2.ms["master2"].schema.add_schema('objectClasses', new)
 
-    mod = [(ldap.MOD_REPLACE, 'description', 'Hello world 1')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'Hello world 1')]
     dn = "cn=%s0,%s" % (OTHER_NAME, SUFFIX)
     topology_m2.ms["master2"].modify_s(dn, mod)
 
-    loop = 0
-    while loop <= 10:
-        try:
-            ent = topology_m2.ms["master1"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
-            if ent.hasAttr('description') and (ent.getValue('description') == 'Hello world 1'):
-                break
-        except ldap.NO_SUCH_OBJECT:
-            loop += 1
-        time.sleep(1)
-    assert loop <= 10
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master1"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ensure_str(ent.getValue('description')) == 'Hello world 1'
 
     time.sleep(2)
     schema_csn_master1 = topology_m2.ms["master1"].schema.get_schema_csn()
@@ -168,20 +160,13 @@ def test_ticket47721_1(topology_m2):
 def test_ticket47721_2(topology_m2):
     log.info('Running test 2...')
 
-    mod = [(ldap.MOD_REPLACE, 'description', 'Hello world 2')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'Hello world 2')]
     dn = "cn=%s0,%s" % (OTHER_NAME, SUFFIX)
     topology_m2.ms["master1"].modify_s(dn, mod)
 
-    loop = 0
-    while loop <= 10:
-        try:
-            ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
-            if ent.hasAttr('description') and (ent.getValue('description') == 'Hello world 2'):
-                break
-        except ldap.NO_SUCH_OBJECT:
-            loop += 1
-        time.sleep(1)
-    assert loop <= 10
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ensure_str(ent.getValue('description')) == 'Hello world 2'
 
     time.sleep(2)
     schema_csn_master1 = topology_m2.ms["master1"].schema.get_schema_csn()
@@ -222,20 +207,13 @@ def test_ticket47721_3(topology_m2):
     topology_m2.ms["master2"].schema.add_schema('objectClasses', new)
     time.sleep(1)
 
-    mod = [(ldap.MOD_REPLACE, 'description', 'Hello world 3')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'Hello world 3')]
     dn = "cn=%s0,%s" % (OTHER_NAME, SUFFIX)
     topology_m2.ms["master1"].modify_s(dn, mod)
 
-    loop = 0
-    while loop <= 10:
-        try:
-            ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
-            if ent.hasAttr('description') and (ent.getValue('description') == 'Hello world 3'):
-                break
-        except ldap.NO_SUCH_OBJECT:
-            loop += 1
-        time.sleep(1)
-    assert loop <= 10
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ensure_str(ent.getValue('description')) == 'Hello world 3'
 
     time.sleep(5)
     schema_csn_master1 = topology_m2.ms["master1"].schema.get_schema_csn()
@@ -273,36 +251,22 @@ def test_ticket47721_4(topology_m2):
     topology_m2.ms["master1"].schema.add_schema('objectClasses', new)
 
     topology_m2.ms["master1"].log.info("trigger replication M1->M2: to update the schema")
-    mod = [(ldap.MOD_REPLACE, 'description', 'Hello world 4')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'Hello world 4')]
     dn = "cn=%s0,%s" % (OTHER_NAME, SUFFIX)
     topology_m2.ms["master1"].modify_s(dn, mod)
 
-    loop = 0
-    while loop <= 10:
-        try:
-            ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
-            if ent.hasAttr('description') and (ent.getValue('description') == 'Hello world 4'):
-                break
-        except ldap.NO_SUCH_OBJECT:
-            loop += 1
-        time.sleep(1)
-    assert loop <= 10
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ensure_str(ent.getValue('description')) == 'Hello world 4'
 
     topology_m2.ms["master1"].log.info("trigger replication M1->M2: to push the schema")
-    mod = [(ldap.MOD_REPLACE, 'description', 'Hello world 5')]
+    mod = [(ldap.MOD_REPLACE, 'description', b'Hello world 5')]
     dn = "cn=%s0,%s" % (OTHER_NAME, SUFFIX)
     topology_m2.ms["master1"].modify_s(dn, mod)
 
-    loop = 0
-    while loop <= 10:
-        try:
-            ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
-            if ent.hasAttr('description') and (ent.getValue('description') == 'Hello world 5'):
-                break
-        except ldap.NO_SUCH_OBJECT:
-            loop += 1
-        time.sleep(1)
-    assert loop <= 10
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ensure_str(ent.getValue('description')) == 'Hello world 5'
 
     time.sleep(2)
     schema_csn_master1 = topology_m2.ms["master1"].schema.get_schema_csn()
diff --git a/dirsrvtests/tests/tickets/ticket47781_test.py b/dirsrvtests/tests/tickets/ticket47781_test.py
index ed69f64..1949154 100644
--- a/dirsrvtests/tests/tickets/ticket47781_test.py
+++ b/dirsrvtests/tests/tickets/ticket47781_test.py
@@ -11,6 +11,7 @@ import logging
 import pytest
 from lib389.tasks import *
 from lib389.topologies import topology_st
+from lib389.replica import ReplicationManager
 
 from lib389._constants import (defaultProperties, DEFAULT_SUFFIX, ReplicaRole,
                                REPLICAID_MASTER_1, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
@@ -28,12 +29,9 @@ def test_ticket47781(topology_st):
 
     log.info('Testing Ticket 47781 - Testing for deadlock after importing LDIF with replication data')
 
-    #
-    # Setup Replication
-    #
-    log.info('Setting up replication...')
-    topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.MASTER,
-                                                     replicaId=REPLICAID_MASTER_1)
+    master = topology_st.standalone
+    repl = ReplicationManager(DEFAULT_SUFFIX)
+    repl.create_first_master(master)
 
     properties = {RA_NAME: r'meTo_$host:$port',
                   RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
@@ -41,77 +39,59 @@ def test_ticket47781(topology_st):
                   RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
                   RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
     # The agreement should point to a server that does NOT exist (invalid port)
-    repl_agreement = topology_st.standalone.agreement.create(suffix=DEFAULT_SUFFIX,
-                                                             host=topology_st.standalone.host,
-                                                             port=5555,
-                                                             properties=properties)
+    repl_agreement = master.agreement.create(suffix=DEFAULT_SUFFIX,
+                                             host=master.host,
+                                             port=5555,
+                                             properties=properties)
 
     #
     # add two entries
     #
     log.info('Adding two entries...')
-    try:
-        topology_st.standalone.add_s(Entry(('cn=entry1,dc=example,dc=com', {
-            'objectclass': 'top person'.split(),
-            'sn': 'user',
-            'cn': 'entry1'})))
-    except ldap.LDAPError as e:
-        log.error('Failed to add entry 1: ' + e.message['desc'])
-        assert False
-
-    try:
-        topology_st.standalone.add_s(Entry(('cn=entry2,dc=example,dc=com', {
-            'objectclass': 'top person'.split(),
-            'sn': 'user',
-            'cn': 'entry2'})))
-    except ldap.LDAPError as e:
-        log.error('Failed to add entry 2: ' + e.message['desc'])
-        assert False
+
+    master.add_s(Entry(('cn=entry1,dc=example,dc=com', {
+        'objectclass': 'top person'.split(),
+        'sn': 'user',
+        'cn': 'entry1'})))
+
+    master.add_s(Entry(('cn=entry2,dc=example,dc=com', {
+        'objectclass': 'top person'.split(),
+        'sn': 'user',
+        'cn': 'entry2'})))
 
     #
     # export the replication ldif
     #
     log.info('Exporting replication ldif...')
     args = {EXPORT_REPL_INFO: True}
-    exportTask = Tasks(topology_st.standalone)
-    try:
-        exportTask.exportLDIF(DEFAULT_SUFFIX, None, "/tmp/export.ldif", args)
-    except ValueError:
-        assert False
+    exportTask = Tasks(master)
+    exportTask.exportLDIF(DEFAULT_SUFFIX, None, "/tmp/export.ldif", args)
 
     #
     # Restart the server
     #
     log.info('Restarting server...')
-    topology_st.standalone.stop()
-    topology_st.standalone.start()
+    master.stop()
+    master.start()
 
     #
     # Import the ldif
     #
     log.info('Import replication LDIF file...')
-    importTask = Tasks(topology_st.standalone)
+    importTask = Tasks(master)
     args = {TASK_WAIT: True}
-    try:
-        importTask.importLDIF(DEFAULT_SUFFIX, None, "/tmp/export.ldif", args)
-        os.remove("/tmp/export.ldif")
-    except ValueError:
-        os.remove("/tmp/export.ldif")
-        assert False
+    importTask.importLDIF(DEFAULT_SUFFIX, None, "/tmp/export.ldif", args)
+    os.remove("/tmp/export.ldif")
 
     #
     # Search for tombstones - we should not hang/timeout
     #
     log.info('Search for tombstone entries(should find one and not hang)...')
-    topology_st.standalone.set_option(ldap.OPT_NETWORK_TIMEOUT, 5)
-    topology_st.standalone.set_option(ldap.OPT_TIMEOUT, 5)
-    try:
-        entries = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, 'objectclass=nsTombstone')
-        if not entries:
-            log.fatal('Search failed to find any entries.')
-            assert PR_False
-    except ldap.LDAPError as e:
-        log.fatal('Search failed: ' + e.message['desc'])
+    master.set_option(ldap.OPT_NETWORK_TIMEOUT, 5)
+    master.set_option(ldap.OPT_TIMEOUT, 5)
+    entries = master.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, 'objectclass=nsTombstone')
+    if not entries:
+        log.fatal('Search failed to find any entries.')
         assert PR_False
 
 
diff --git a/dirsrvtests/tests/tickets/ticket47787_test.py b/dirsrvtests/tests/tickets/ticket47787_test.py
index 3e10dc9..306e70d 100644
--- a/dirsrvtests/tests/tickets/ticket47787_test.py
+++ b/dirsrvtests/tests/tickets/ticket47787_test.py
@@ -20,6 +20,7 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_m2
+from lib389.utils import *
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
@@ -187,7 +188,7 @@ def _find_tombstone(instance, base, attr, value):
     for ent in ents:
         if ent.hasAttr(attr):
             for val in ent.getValues(attr):
-                if val == value:
+                if ensure_str(val) == value:
                     instance.log.debug("tombstone found: %r" % ent)
                     return ent
     return None
@@ -198,12 +199,13 @@ def _delete_entry(instance, entry_dn, name):
 
     # delete the entry
     instance.delete_s(entry_dn)
-    assert _find_tombstone(instance, SUFFIX, 'sn', name) is not None
+    ent = _find_tombstone(instance, SUFFIX, 'sn', name)
+    assert ent is not None
 
 
 def _mod_entry(instance, entry_dn, attr, value):
     instance.log.info("\n\n######################### MOD %s (M2) ######################\n" % entry_dn)
-    mod = [(ldap.MOD_REPLACE, attr, value)]
+    mod = [(ldap.MOD_REPLACE, attr, ensure_bytes(value))]
     instance.modify_s(entry_dn, mod)
 
 
@@ -262,7 +264,7 @@ def _check_replication(topology_m2, entry_dn):
     while loop <= 10:
         attr = 'description'
         value = 'test_value_%d' % loop
-        mod = [(ldap.MOD_REPLACE, attr, value)]
+        mod = [(ldap.MOD_REPLACE, attr, ensure_bytes(value))]
         topology_m2.ms["master1"].modify_s(entry_dn, mod)
         _check_mod_received(topology_m2.ms["master2"], SUFFIX, filt, attr, value)
         loop += 1
@@ -272,7 +274,7 @@ def _check_replication(topology_m2, entry_dn):
     while loop <= 10:
         attr = 'description'
         value = 'test_value_%d' % loop
-        mod = [(ldap.MOD_REPLACE, attr, value)]
+        mod = [(ldap.MOD_REPLACE, attr, ensure_bytes(value))]
         topology_m2.ms["master2"].modify_s(entry_dn, mod)
         _check_mod_received(topology_m2.ms["master1"], SUFFIX, filt, attr, value)
         loop += 1
@@ -312,7 +314,7 @@ def test_ticket47787_init(topology_m2):
         'description': "production DIT"})))
 
     # enable replication error logging
-    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '8192')]
+    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'8192')]
     topology_m2.ms["master1"].modify_s(DN_CONFIG, mod)
     topology_m2.ms["master2"].modify_s(DN_CONFIG, mod)
 
@@ -414,7 +416,7 @@ def test_ticket47787_2(topology_m2):
     assert loop <= 10
     assert ent
     assert ent.hasAttr(attr)
-    assert ent.getValue(attr) == value
+    assert ensure_str(ent.getValue(attr)) == value
 
 
 if __name__ == '__main__':
diff --git a/dirsrvtests/tests/tickets/ticket47808_test.py b/dirsrvtests/tests/tickets/ticket47808_test.py
index d2c7425..074f5e1 100644
--- a/dirsrvtests/tests/tickets/ticket47808_test.py
+++ b/dirsrvtests/tests/tickets/ticket47808_test.py
@@ -13,6 +13,7 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_st
+from lib389.utils import *
 
 log = logging.getLogger(__name__)
 
@@ -36,8 +37,8 @@ def test_ticket47808_run(topology_st):
     topology_st.standalone.log.info("\n\n######################### SETUP ATTR UNIQ PLUGIN ######################\n")
 
     # enable attribute uniqueness plugin
-    mod = [(ldap.MOD_REPLACE, 'nsslapd-pluginEnabled', 'on'), (ldap.MOD_REPLACE, 'nsslapd-pluginarg0', 'sn'),
-           (ldap.MOD_REPLACE, 'nsslapd-pluginarg1', SUFFIX)]
+    mod = [(ldap.MOD_REPLACE, 'nsslapd-pluginEnabled', b'on'), (ldap.MOD_REPLACE, 'nsslapd-pluginarg0', b'sn'),
+           (ldap.MOD_REPLACE, 'nsslapd-pluginarg1', ensure_bytes(SUFFIX))]
     topology_st.standalone.modify_s(ATTRIBUTE_UNIQUENESS_PLUGIN, mod)
 
     topology_st.standalone.log.info("\n\n######################### ADD USER 1 ######################\n")
diff --git a/dirsrvtests/tests/tickets/ticket47819_test.py b/dirsrvtests/tests/tickets/ticket47819_test.py
index f7b5289..3955430 100644
--- a/dirsrvtests/tests/tickets/ticket47819_test.py
+++ b/dirsrvtests/tests/tickets/ticket47819_test.py
@@ -11,6 +11,7 @@ import logging
 import pytest
 from lib389.tasks import *
 from lib389.topologies import topology_st
+from lib389.replica import ReplicationManager
 
 from lib389._constants import (defaultProperties, DEFAULT_SUFFIX, ReplicaRole,
                                REPLICAID_MASTER_1, REPLICA_PRECISE_PURGING, REPLICA_PURGE_DELAY,
@@ -38,9 +39,10 @@ pytestmark = pytest.mark.skipif(ds_is_older('1.3.4'), reason="Not implemented")
     #
     # Setup Replication
     #
-    log.info('Setting up replication...')
-    topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.MASTER,
-                                                     replicaId=REPLICAID_MASTER_1)
+    master = topology_st.standalone
+    repl = ReplicationManager(DEFAULT_SUFFIX)
+    repl.create_first_master(master)
+    repl.ensure_agreement(master, master)
 
     #
     # Part 1 create a tombstone entry and make sure nsTombstoneCSN is added
@@ -190,9 +192,9 @@ pytestmark = pytest.mark.skipif(ds_is_older('1.3.4'), reason="Not implemented")
     #
     log.info('Part 4:  test tombstone purging...')
 
-    args = {REPLICA_PRECISE_PURGING: 'on',
-            REPLICA_PURGE_DELAY: '5',
-            REPLICA_PURGE_INTERVAL: '5'}
+    args = {REPLICA_PRECISE_PURGING: b'on',
+            REPLICA_PURGE_DELAY: b'5',
+            REPLICA_PURGE_INTERVAL: b'5'}
     try:
         topology_st.standalone.replica.setProperties(DEFAULT_SUFFIX, None, None, args)
     except:
diff --git a/dirsrvtests/tests/tickets/ticket47823_test.py b/dirsrvtests/tests/tickets/ticket47823_test.py
index 7f4aa86..3724ace 100644
--- a/dirsrvtests/tests/tickets/ticket47823_test.py
+++ b/dirsrvtests/tests/tickets/ticket47823_test.py
@@ -201,7 +201,7 @@ def _active_container_mod(topology_st, type_config='old'):
         'cn': ACTIVE_USER_2_CN})))
 
     try:
-        topology_st.standalone.modify_s(ACTIVE_USER_2_DN, [(ldap.MOD_ADD, 'cn', ACTIVE_USER_1_CN)])
+        topology_st.standalone.modify_s(ACTIVE_USER_2_DN, [(ldap.MOD_ADD, 'cn', ensure_bytes(ACTIVE_USER_1_CN))])
     except ldap.CONSTRAINT_VIOLATION:
         # yes it is expected
         pass
@@ -209,7 +209,7 @@ def _active_container_mod(topology_st, type_config='old'):
     topology_st.standalone.log.info('Uniqueness enforced: checks MOD REPLACE entry is rejected')
     try:
         topology_st.standalone.modify_s(ACTIVE_USER_2_DN,
-                                        [(ldap.MOD_REPLACE, 'cn', [ACTIVE_USER_1_CN, ACTIVE_USER_2_CN])])
+                                        [(ldap.MOD_REPLACE, 'cn', [ensure_bytes(ACTIVE_USER_1_CN), ensure_bytes(ACTIVE_USER_2_CN)])])
     except ldap.CONSTRAINT_VIOLATION:
         # yes it is expected
         pass
@@ -316,7 +316,7 @@ def _active_stage_containers_mod(topology_st, type_config='old', across_subtrees
     try:
 
         # modify add same value
-        topology_st.standalone.modify_s(STAGE_USER_1_DN, [(ldap.MOD_ADD, 'cn', [ACTIVE_USER_2_CN])])
+        topology_st.standalone.modify_s(STAGE_USER_1_DN, [(ldap.MOD_ADD, 'cn', [ensure_bytes(ACTIVE_USER_2_CN)])])
     except ldap.CONSTRAINT_VIOLATION:
         assert across_subtrees
 
@@ -328,7 +328,7 @@ def _active_stage_containers_mod(topology_st, type_config='old', across_subtrees
     try:
         # modify replace same value
         topology_st.standalone.modify_s(STAGE_USER_1_DN,
-                                        [(ldap.MOD_REPLACE, 'cn', [STAGE_USER_2_CN, ACTIVE_USER_1_CN])])
+                                        [(ldap.MOD_REPLACE, 'cn', [ensure_bytes(STAGE_USER_2_CN), ensure_bytes(ACTIVE_USER_1_CN)])])
     except ldap.CONSTRAINT_VIOLATION:
         assert across_subtrees
 
@@ -371,7 +371,7 @@ def _active_stage_containers_modrdn(topology_st, type_config='old', across_subtr
         assert stage_ent.hasAttr('cn')
         found = False
         for value in stage_ent.getValues('cn'):
-            if value == 'dummy':
+            if ensure_str(value) == 'dummy':
                 found = True
         assert found
 
@@ -380,7 +380,7 @@ def _active_stage_containers_modrdn(topology_st, type_config='old', across_subtr
         assert active_ent.hasAttr('cn')
         found = False
         for value in stage_ent.getValues('cn'):
-            if value == 'dummy':
+            if ensure_str(value) == 'dummy':
                 found = True
         assert found
 
@@ -607,7 +607,7 @@ def test_ticket47823_invalid_config_1(topology_st):
     topology_st.standalone.getEntry(config.dn, ldap.SCOPE_BASE, "(objectclass=nsSlapdPlugin)", ALL_CONFIG_ATTRS)
 
     # Check the server did not restart
-    topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '65536')])
+    topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'65536')])
     try:
         topology_st.standalone.restart()
         ent = topology_st.standalone.getEntry(config.dn, ldap.SCOPE_BASE, "(objectclass=nsSlapdPlugin)",
@@ -715,7 +715,7 @@ def test_ticket47823_invalid_config_3(topology_st):
     topology_st.standalone.getEntry(config.dn, ldap.SCOPE_BASE, "(objectclass=nsSlapdPlugin)", ALL_CONFIG_ATTRS)
 
     # Check the server did not restart
-    topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '65536')])
+    topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'65536')])
     try:
         topology_st.standalone.restart()
         ent = topology_st.standalone.getEntry(config.dn, ldap.SCOPE_BASE, "(objectclass=nsSlapdPlugin)",
@@ -917,7 +917,7 @@ def test_ticket47823_invalid_config_7(topology_st):
     config = _build_config(topology_st, attr_name='cn', subtree_1="this_is dummy DN", subtree_2="an other=dummy DN",
                            type_config='new', across_subtrees=False)
 
-    topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '65536')])
+    topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'65536')])
     # replace 'cn' uniqueness entry
     try:
         topology_st.standalone.delete_s(config.dn)
diff --git a/dirsrvtests/tests/tickets/ticket47828_test.py b/dirsrvtests/tests/tickets/ticket47828_test.py
index 55d65ed..aea3490 100644
--- a/dirsrvtests/tests/tickets/ticket47828_test.py
+++ b/dirsrvtests/tests/tickets/ticket47828_test.py
@@ -81,8 +81,8 @@ def test_ticket47828_run_0(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -99,8 +99,8 @@ def test_ticket47828_run_1(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -117,8 +117,8 @@ def test_ticket47828_run_2(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -135,8 +135,8 @@ def test_ticket47828_run_3(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -147,7 +147,7 @@ def test_ticket47828_run_4(topology_st):
     _header(topology_st, 'Exclude the provisioning container')
 
     dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
-    mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', PROVISIONING)]
+    mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', ensure_bytes(PROVISIONING))]
     topology_st.standalone.modify_s(dn_config, mod)
 
 
@@ -164,8 +164,8 @@ def test_ticket47828_run_5(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ensure_str(ent.getValue(ALLOCATED_ATTR))) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ensure_str(ent.getValue(ALLOCATED_ATTR)))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -183,8 +183,8 @@ def test_ticket47828_run_6(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ensure_str(ent.getValue(ALLOCATED_ATTR))) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ensure_str(ent.getValue(ALLOCATED_ATTR)))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -201,8 +201,8 @@ def test_ticket47828_run_7(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -220,8 +220,8 @@ def test_ticket47828_run_8(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -238,8 +238,8 @@ def test_ticket47828_run_9(topology_st):
                                 ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(DUMMY_USER1_DN)
 
 
@@ -257,8 +257,8 @@ def test_ticket47828_run_10(topology_st):
                                 ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(DUMMY_USER1_DN)
 
 
@@ -269,7 +269,7 @@ def test_ticket47828_run_11(topology_st):
     _header(topology_st, 'Exclude (in addition) the dummy container')
 
     dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
-    mod = [(ldap.MOD_ADD, 'dnaExcludeScope', DUMMY_CONTAINER)]
+    mod = [(ldap.MOD_ADD, 'dnaExcludeScope', ensure_bytes(DUMMY_CONTAINER))]
     topology_st.standalone.modify_s(dn_config, mod)
 
 
@@ -286,8 +286,8 @@ def test_ticket47828_run_12(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -305,8 +305,8 @@ def test_ticket47828_run_13(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -324,8 +324,8 @@ def test_ticket47828_run_14(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -343,8 +343,8 @@ def test_ticket47828_run_15(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -362,8 +362,8 @@ def test_ticket47828_run_16(topology_st):
                                 ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(DUMMY_USER1_DN)
 
 
@@ -381,8 +381,8 @@ def test_ticket47828_run_17(topology_st):
                                 ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(DUMMY_USER1_DN)
 
 
@@ -393,10 +393,10 @@ def test_ticket47828_run_18(topology_st):
     _header(topology_st, 'Exclude PROVISIONING and a wrong container')
 
     dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
-    mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', PROVISIONING)]
+    mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', ensure_bytes(PROVISIONING))]
     topology_st.standalone.modify_s(dn_config, mod)
     try:
-        mod = [(ldap.MOD_ADD, 'dnaExcludeScope', "invalidDN,%s" % SUFFIX)]
+        mod = [(ldap.MOD_ADD, 'dnaExcludeScope', ensure_bytes("invalidDN,%s" % SUFFIX))]
         topology_st.standalone.modify_s(dn_config, mod)
         raise ValueError("invalid dnaExcludeScope value (not a DN)")
     except ldap.INVALID_SYNTAX:
@@ -417,8 +417,8 @@ def test_ticket47828_run_19(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -436,8 +436,8 @@ def test_ticket47828_run_20(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -455,8 +455,8 @@ def test_ticket47828_run_21(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -474,8 +474,8 @@ def test_ticket47828_run_22(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -493,8 +493,8 @@ def test_ticket47828_run_23(topology_st):
                                 ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(DUMMY_USER1_DN)
 
 
@@ -512,8 +512,8 @@ def test_ticket47828_run_24(topology_st):
                                 ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(DUMMY_USER1_DN)
 
 
@@ -526,7 +526,7 @@ def test_ticket47828_run_25(topology_st):
     dn_config = "cn=excluded scope, cn=%s, %s" % (PLUGIN_DNA, DN_PLUGIN)
 
     try:
-        mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', "invalidDN,%s" % SUFFIX)]
+        mod = [(ldap.MOD_REPLACE, 'dnaExcludeScope', ensure_bytes("invalidDN,%s" % SUFFIX))]
         topology_st.standalone.modify_s(dn_config, mod)
         raise ValueError("invalid dnaExcludeScope value (not a DN)")
     except ldap.INVALID_SYNTAX:
@@ -546,8 +546,8 @@ def test_ticket47828_run_26(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -565,8 +565,8 @@ def test_ticket47828_run_27(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(ACTIVE_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (ACTIVE_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(ACTIVE_USER1_DN)
 
 
@@ -583,8 +583,8 @@ def test_ticket47828_run_28(topology_st):
                                  ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -602,8 +602,8 @@ def test_ticket47828_run_29(topology_st):
                                  ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(STAGED_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (STAGED_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(STAGED_USER1_DN)
 
 
@@ -620,8 +620,8 @@ def test_ticket47828_run_30(topology_st):
                                 ALLOCATED_ATTR: str(-1)})))
     ent = topology_st.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) != str(-1)
-    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) != str(-1)
+    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(DUMMY_USER1_DN)
 
 
@@ -639,8 +639,8 @@ def test_ticket47828_run_31(topology_st):
                                 ALLOCATED_ATTR: str(20)})))
     ent = topology_st.standalone.getEntry(DUMMY_USER1_DN, ldap.SCOPE_BASE, "(objectclass=*)")
     assert ent.hasAttr(ALLOCATED_ATTR)
-    assert ent.getValue(ALLOCATED_ATTR) == str(20)
-    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ent.getValue(ALLOCATED_ATTR)))
+    assert ensure_str(ent.getValue(ALLOCATED_ATTR)) == str(20)
+    topology_st.standalone.log.debug('%s.%s=%s' % (DUMMY_USER1_CN, ALLOCATED_ATTR, ensure_str(ent.getValue(ALLOCATED_ATTR))))
     topology_st.standalone.delete_s(DUMMY_USER1_DN)
 
 
diff --git a/dirsrvtests/tests/tickets/ticket47829_test.py b/dirsrvtests/tests/tickets/ticket47829_test.py
index 72a42d7..8f1a872 100644
--- a/dirsrvtests/tests/tickets/ticket47829_test.py
+++ b/dirsrvtests/tests/tickets/ticket47829_test.py
@@ -93,7 +93,7 @@ def _find_memberof(topology_st, user_dn=None, group_dn=None, find_result=True):
 
         for val in ent.getValues('memberof'):
             topology_st.standalone.log.info("!!!!!!! %s: memberof->%s" % (user_dn, val))
-            if val == group_dn:
+            if ensure_str(val) == group_dn:
                 found = True
                 break
 
@@ -113,7 +113,7 @@ def _find_member(topology_st, user_dn=None, group_dn=None, find_result=True):
 
         for val in ent.getValues('member'):
             topology_st.standalone.log.info("!!!!!!! %s: member ->%s" % (group_dn, val))
-            if val == user_dn:
+            if ensure_str(val) == user_dn:
                 found = True
                 break
 
@@ -171,7 +171,7 @@ def _check_memberof(topology_st=None, action=None, user_dn=None, group_dn=None, 
     topology_st.standalone.log.info('\n%s entry %s' % (txt, user_dn))
     topology_st.standalone.log.info('to group %s' % group_dn)
 
-    topology_st.standalone.modify_s(group_dn, [(action, 'member', user_dn)])
+    topology_st.standalone.modify_s(group_dn, [(action, 'member', ensure_bytes(user_dn))])
     time.sleep(1)
     _find_memberof(topology_st, user_dn=user_dn, group_dn=group_dn, find_result=find_result)
 
@@ -218,15 +218,15 @@ def test_ticket47829_init(topology_st):
     # enable memberof of with scope IN except provisioning
     topology_st.standalone.plugins.enable(name=PLUGIN_MEMBER_OF)
     dn = "cn=%s,%s" % (PLUGIN_MEMBER_OF, DN_PLUGIN)
-    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'memberOfEntryScope', SCOPE_IN_DN)])
-    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'memberOfEntryScopeExcludeSubtree', PROVISIONING_DN)])
+    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'memberOfEntryScope', ensure_bytes(SCOPE_IN_DN))])
+    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'memberOfEntryScopeExcludeSubtree', ensure_bytes(PROVISIONING_DN))])
 
     # enable RI with scope IN except provisioning
     topology_st.standalone.plugins.enable(name=PLUGIN_REFER_INTEGRITY)
     dn = "cn=%s,%s" % (PLUGIN_REFER_INTEGRITY, DN_PLUGIN)
-    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'nsslapd-pluginentryscope', SCOPE_IN_DN)])
-    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'nsslapd-plugincontainerscope', SCOPE_IN_DN)])
-    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'nsslapd-pluginExcludeEntryScope', PROVISIONING_DN)])
+    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'nsslapd-pluginentryscope', ensure_bytes(SCOPE_IN_DN))])
+    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'nsslapd-plugincontainerscope', ensure_bytes(SCOPE_IN_DN))])
+    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'nsslapd-pluginExcludeEntryScope', ensure_bytes(PROVISIONING_DN))])
 
     topology_st.standalone.restart(timeout=10)
 
@@ -494,7 +494,7 @@ def test_ticket47829_mod_stage_user_modrdn_stage_user_1(topology_st):
 def test_ticket47829_indirect_active_group_1(topology_st):
     _header(topology_st, 'add an Active group (G1) to an active group (G0). Then add active user to G1')
 
-    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_ADD, 'member', ACTIVE_GROUP_DN)])
+    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_ADD, 'member', ensure_bytes(ACTIVE_GROUP_DN))])
 
     # add an active user to G1. Checks that user is memberof G1
     _check_memberof(topology_st, action=ldap.MOD_ADD, user_dn=ACTIVE_USER_DN, group_dn=ACTIVE_GROUP_DN,
@@ -502,7 +502,7 @@ def test_ticket47829_indirect_active_group_1(topology_st):
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=INDIRECT_ACTIVE_GROUP_DN, find_result=True)
 
     # remove G1 from G0
-    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_DELETE, 'member', ACTIVE_GROUP_DN)])
+    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_DELETE, 'member', ensure_bytes(ACTIVE_GROUP_DN))])
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=INDIRECT_ACTIVE_GROUP_DN, find_result=False)
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=ACTIVE_GROUP_DN, find_result=True)
 
@@ -515,7 +515,7 @@ def test_ticket47829_indirect_active_group_2(topology_st):
     _header(topology_st,
             'add an Active group (G1) to an active group (G0). Then add active user to G1. Then move active user to stage')
 
-    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_ADD, 'member', ACTIVE_GROUP_DN)])
+    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_ADD, 'member', ensure_bytes(ACTIVE_GROUP_DN))])
 
     # add an active user to G1. Checks that user is memberof G1
     _check_memberof(topology_st, action=ldap.MOD_ADD, user_dn=ACTIVE_USER_DN, group_dn=ACTIVE_GROUP_DN,
@@ -523,7 +523,7 @@ def test_ticket47829_indirect_active_group_2(topology_st):
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=INDIRECT_ACTIVE_GROUP_DN, find_result=True)
 
     # remove G1 from G0
-    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_DELETE, 'member', ACTIVE_GROUP_DN)])
+    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_DELETE, 'member', ensure_bytes(ACTIVE_GROUP_DN))])
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=INDIRECT_ACTIVE_GROUP_DN, find_result=False)
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=ACTIVE_GROUP_DN, find_result=True)
 
@@ -555,7 +555,7 @@ def test_ticket47829_indirect_active_group_3(topology_st):
     _header(topology_st,
             'add an Active group (G1) to an active group (G0). Then add active user to G1. Then move active user to out of the scope')
 
-    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_ADD, 'member', ACTIVE_GROUP_DN)])
+    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_ADD, 'member', ensure_bytes(ACTIVE_GROUP_DN))])
 
     # add an active user to G1. Checks that user is memberof G1
     _check_memberof(topology_st, action=ldap.MOD_ADD, user_dn=ACTIVE_USER_DN, group_dn=ACTIVE_GROUP_DN,
@@ -563,7 +563,7 @@ def test_ticket47829_indirect_active_group_3(topology_st):
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=INDIRECT_ACTIVE_GROUP_DN, find_result=True)
 
     # remove G1 from G0
-    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_DELETE, 'member', ACTIVE_GROUP_DN)])
+    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_DELETE, 'member', ensure_bytes(ACTIVE_GROUP_DN))])
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=INDIRECT_ACTIVE_GROUP_DN, find_result=False)
     _find_memberof(topology_st, user_dn=ACTIVE_USER_DN, group_dn=ACTIVE_GROUP_DN, find_result=True)
 
@@ -595,7 +595,7 @@ def test_ticket47829_indirect_active_group_4(topology_st):
     _header(topology_st,
             'add an Active group (G1) to an active group (G0). Then add stage user to G1. Then move user to active. Then move it back')
 
-    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_ADD, 'member', ACTIVE_GROUP_DN)])
+    topology_st.standalone.modify_s(INDIRECT_ACTIVE_GROUP_DN, [(ldap.MOD_ADD, 'member', ensure_bytes(ACTIVE_GROUP_DN))])
 
     # add stage user to active group
     _check_memberof(topology_st, action=ldap.MOD_ADD, user_dn=STAGE_USER_DN, group_dn=ACTIVE_GROUP_DN,
diff --git a/dirsrvtests/tests/tickets/ticket47833_test.py b/dirsrvtests/tests/tickets/ticket47833_test.py
index 9267365..810cba9 100644
--- a/dirsrvtests/tests/tickets/ticket47833_test.py
+++ b/dirsrvtests/tests/tickets/ticket47833_test.py
@@ -109,7 +109,7 @@ def _find_member(topology_st, user_dn=None, group_dn=None, find_result=True):
 
         for val in ent.getValues('member'):
             topology_st.standalone.log.info("!!!!!!! %s: member ->%s" % (group_dn, val))
-            if val == user_dn:
+            if ensure_str(val) == user_dn:
                 found = True
                 break
 
@@ -144,7 +144,7 @@ def _check_memberof(topology_st=None, action=None, user_dn=None, group_dn=None, 
     topology_st.standalone.log.info('\n%s entry %s' % (txt, user_dn))
     topology_st.standalone.log.info('to group %s' % group_dn)
 
-    topology_st.standalone.modify_s(group_dn, [(action, 'member', user_dn)])
+    topology_st.standalone.modify_s(group_dn, [(action, 'member', ensure_bytes(user_dn))])
     time.sleep(1)
     _find_memberof(topology_st, user_dn=user_dn, group_dn=group_dn, find_result=find_result)
 
@@ -188,7 +188,7 @@ def test_ticket47829_init(topology_st):
     # enable memberof of with scope account
     topology_st.standalone.plugins.enable(name=PLUGIN_MEMBER_OF)
     dn = "cn=%s,%s" % (PLUGIN_MEMBER_OF, DN_PLUGIN)
-    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'memberOfEntryScope', ACTIVE_DN)])
+    topology_st.standalone.modify_s(dn, [(ldap.MOD_REPLACE, 'memberOfEntryScope', ensure_bytes(ACTIVE_DN))])
 
     topology_st.standalone.restart(timeout=10)
 
diff --git a/dirsrvtests/tests/tickets/ticket47838_test.py b/dirsrvtests/tests/tickets/ticket47838_test.py
index 2da485b..38521d5 100644
--- a/dirsrvtests/tests/tickets/ticket47838_test.py
+++ b/dirsrvtests/tests/tickets/ticket47838_test.py
@@ -15,6 +15,7 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_st
+from lib389.nss_ssl import NssSsl
 
 log = logging.getLogger(__name__)
 
@@ -24,7 +25,7 @@ from lib389.utils import *
 # Skip on older versions
 pytestmark = pytest.mark.skipif(ds_is_older('1.3.3'), reason="Not implemented")
 ENCRYPTION_DN = 'cn=encryption,%s' % CONFIG_DN
-MY_SECURE_PORT = '36363'
+MY_SECURE_PORT = '63601'
 RSA = 'RSA'
 RSA_DN = 'cn=%s,%s' % (RSA, ENCRYPTION_DN)
 SERVERCERT = 'Server-Cert'
@@ -57,26 +58,25 @@ def test_47838_init(topology_st):
     Enable SSL
     """
     _header(topology_st, 'Testing Ticket 47838 - harden the list of ciphers available by default')
-
     onss_version = os.popen("rpm -q nss | awk -F'-' '{print $2}'", "r")
     global nss_version
     nss_version = onss_version.readline()
-
-    topology_st.standalone.nss_ssl.reinit()
-    topology_st.standalone.nss_ssl.create_rsa_ca()
-    topology_st.standalone.nss_ssl.create_rsa_key_and_cert()
+    nss_ssl = NssSsl(dbpath=topology_st.standalone.get_cert_dir())
+    nss_ssl.reinit()
+    nss_ssl.create_rsa_ca()
+    nss_ssl.create_rsa_key_and_cert()
 
     log.info("\n######################### enable SSL in the directory server with all ciphers ######################\n")
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3', 'off'),
-                                                    (ldap.MOD_REPLACE, 'nsTLS1', 'on'),
-                                                    (ldap.MOD_REPLACE, 'nsSSLClientAuth', 'allowed'),
-                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', 'on'),
-                                                    (ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+all')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3', b'off'),
+                                                    (ldap.MOD_REPLACE, 'nsTLS1', b'on'),
+                                                    (ldap.MOD_REPLACE, 'nsSSLClientAuth', b'allowed'),
+                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', b'on'),
+                                                    (ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'+all')])
 
-    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-security', 'on'),
-                                                (ldap.MOD_REPLACE, 'nsslapd-ssl-check-hostname', 'off'),
-                                                (ldap.MOD_REPLACE, 'nsslapd-secureport', MY_SECURE_PORT)])
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-security', b'on'),
+                                                (ldap.MOD_REPLACE, 'nsslapd-ssl-check-hostname', b'off'),
+                                                (ldap.MOD_REPLACE, 'nsslapd-secureport', ensure_bytes(MY_SECURE_PORT))])
 
     topology_st.standalone.add_s(Entry((RSA_DN, {'objectclass': "top nsEncryptionModule".split(),
                                                  'cn': RSA,
@@ -111,9 +111,8 @@ def test_47838_run_0(topology_st):
     Note: allowWeakCipher: on
     """
     _header(topology_st, 'Test Case 1 - Check the ciphers availability for "+all"; allowWeakCipher: on')
-
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')])
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'64')])
     time.sleep(5)
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.restart(timeout=120)
@@ -152,7 +151,7 @@ def test_47838_run_1(topology_st):
     _header(topology_st, 'Test Case 2 - Check the ciphers availability for "+all" with default allowWeakCiphers')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')])
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'64')])
     time.sleep(1)
     # Make sure allowWeakCipher is not set.
     topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'allowWeakCipher', None)])
@@ -198,7 +197,7 @@ def test_47838_run_2(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     topology_st.standalone.modify_s(ENCRYPTION_DN,
-                                    [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+rsa_aes_128_sha,+rsa_aes_256_sha')])
+                                    [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'+rsa_aes_128_sha,+rsa_aes_256_sha')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -231,7 +230,7 @@ def test_47838_run_3(topology_st):
     _header(topology_st, 'Test Case 4 - Check the ciphers availability for "-all"')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '-all')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'-all')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -263,7 +262,7 @@ def test_47838_run_4(topology_st):
     _header(topology_st, 'Test Case 5 - Check no nsSSL3Ciphers (default setting) with default allowWeakCipher')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'nsSSL3Ciphers', '-all')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'nsSSL3Ciphers', b'-all')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -271,7 +270,6 @@ def test_47838_run_4(topology_st):
     os.system('touch %s' % (topology_st.standalone.errlog))
     time.sleep(1)
     topology_st.standalone.start(timeout=120)
-
     enabled = os.popen('egrep "SSL info:" %s | egrep \": enabled\" | wc -l' % topology_st.standalone.errlog)
     disabled = os.popen('egrep "SSL info:" %s | egrep \": disabled\" | wc -l' % topology_st.standalone.errlog)
     ecount = int(enabled.readline().rstrip())
@@ -282,7 +280,7 @@ def test_47838_run_4(topology_st):
     global plus_all_ecount
     global plus_all_dcount
     if nss_version >= NSS330:
-        assert ecount == 26
+        assert ecount == 28
     elif nss_version >= NSS323:
         assert ecount == 29
     else:
@@ -306,7 +304,7 @@ def test_47838_run_5(topology_st):
     _header(topology_st, 'Test Case 6 - Check default nsSSL3Ciphers (default setting) with default allowWeakCipher')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'default')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'default')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -325,7 +323,7 @@ def test_47838_run_5(topology_st):
     global plus_all_ecount
     global plus_all_dcount
     if nss_version >= NSS330:
-        assert ecount == 26
+        assert ecount == 28
     elif nss_version >= NSS323:
         assert ecount == 29
     else:
@@ -351,7 +349,7 @@ def test_47838_run_6(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     topology_st.standalone.modify_s(ENCRYPTION_DN,
-                                    [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+all,-tls_dhe_rsa_aes_128_gcm_sha')])
+                                    [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'+all,-tls_dhe_rsa_aes_128_gcm_sha')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -386,7 +384,7 @@ def test_47838_run_7(topology_st):
     _header(topology_st, 'Test Case 8 - Check nsSSL3Ciphers: -all,+rsa_rc4_128_md5 with default allowWeakCipher')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '-all,+rsa_rc4_128_md5')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'-all,+rsa_rc4_128_md5')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -418,8 +416,8 @@ def test_47838_run_8(topology_st):
     _header(topology_st, 'Test Case 9 - Check default nsSSL3Ciphers (default setting + allowWeakCipher: off)')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'default'),
-                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', 'off')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'default'),
+                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', b'off')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -438,7 +436,7 @@ def test_47838_run_8(topology_st):
     global plus_all_ecount
     global plus_all_dcount
     if nss_version >= NSS330:
-        assert ecount == 26
+        assert ecount == 28
     elif nss_version >= NSS323:
         assert ecount == 29
     else:
@@ -465,7 +463,7 @@ def test_47838_run_9(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', None),
-                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', 'on')])
+                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', b'on')])
     topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', None)])
 
     log.info("\n######################### Restarting the server ######################\n")
@@ -483,7 +481,7 @@ def test_47838_run_9(topology_st):
     log.info("Enabled ciphers: %d" % ecount)
     log.info("Disabled ciphers: %d" % dcount)
     if nss_version >= NSS330:
-        assert ecount == 31
+        assert ecount == 33
     elif nss_version >= NSS327:
         assert ecount == 34
     elif nss_version >= NSS323:
@@ -523,7 +521,7 @@ def test_47838_run_10(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers',
-                                                     '-TLS_RSA_WITH_NULL_MD5,+TLS_RSA_WITH_RC4_128_MD5,+TLS_RSA_EXPORT_WITH_RC4_40_MD5,+TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5,+TLS_DHE_RSA_WITH_DES_CBC_SHA,+SSL_RSA_FIPS_WITH_DES_CBC_SHA,+TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,+SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA,+TLS_RSA_EXPORT1024_WITH_RC4_56_SHA,+TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA,-SSL_CK_RC4_128_WITH_MD5,-SSL_CK_RC4_128_EXPORT40_WITH_MD5,-SSL_CK_RC2_128_CBC_WITH_MD5,-SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5,-SSL_CK_DES_64_CBC_WITH_MD5,-SSL_CK_DES_192_EDE3_CBC_WITH_MD5')])
+                                                     b'-TLS_RSA_WITH_NULL_MD5,+TLS_RSA_WITH_RC4_128_MD5,+TLS_RSA_EXPORT_WITH_RC4_40_MD5,+TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5,+TLS_DHE_RSA_WITH_DES_CBC_SHA,+SSL_RSA_FIPS_WITH_DES_CBC_SHA,+TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,+SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA,+TLS_RSA_EXPORT1024_WITH_RC4_56_SHA,+TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA,-SSL_CK_RC4_128_WITH_MD5,-SSL_CK_RC4_128_EXPORT40_WITH_MD5,-SSL_CK_RC2_128_CBC_WITH_MD5,-SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5,-SSL_CK_DES_64_CBC_WITH_MD5,-SSL_CK_DES_192_EDE3_CBC_WITH_MD5')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -564,7 +562,7 @@ def test_47838_run_11(topology_st):
     _header(topology_st, 'Test Case 12 - Check nsSSL3Ciphers: +fortezza, which is not supported')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+fortezza')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'+fortezza')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -593,15 +591,15 @@ def test_47928_run_0(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     # add them once and remove them
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3', 'off'),
-                                                    (ldap.MOD_REPLACE, 'nsTLS1', 'on'),
-                                                    (ldap.MOD_REPLACE, 'sslVersionMin', 'TLS1.1'),
-                                                    (ldap.MOD_REPLACE, 'sslVersionMax', 'TLS1.2')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3', b'off'),
+                                                    (ldap.MOD_REPLACE, 'nsTLS1', b'on'),
+                                                    (ldap.MOD_REPLACE, 'sslVersionMin', b'TLS1.1'),
+                                                    (ldap.MOD_REPLACE, 'sslVersionMax', b'TLS1.2')])
     topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'nsSSL3', None),
                                                     (ldap.MOD_DELETE, 'nsTLS1', None),
                                                     (ldap.MOD_DELETE, 'sslVersionMin', None),
                                                     (ldap.MOD_DELETE, 'sslVersionMax', None)])
-    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')])
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'64')])
     time.sleep(5)
 
     log.info("\n######################### Restarting the server ######################\n")
@@ -629,8 +627,8 @@ def test_47928_run_1(topology_st):
     _header(topology_st, 'Test Case 14 - No nsSSL3, nsTLS1; sslVersionMin > sslVersionMax')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'sslVersionMin', 'TLS1.2'),
-                                                    (ldap.MOD_REPLACE, 'sslVersionMax', 'TLS1.1')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'sslVersionMin', b'TLS1.2'),
+                                                    (ldap.MOD_REPLACE, 'sslVersionMax', b'TLS1.1')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -665,9 +663,9 @@ def test_47928_run_2(topology_st):
     _header(topology_st, 'Test Case 15 - nsSSL3: on; sslVersionMin: TLS1.1; sslVersionMax: TLS1.2')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'sslVersionMin', 'TLS1.1'),
-                                                    (ldap.MOD_REPLACE, 'sslVersionMax', 'TLS1.2'),
-                                                    (ldap.MOD_REPLACE, 'nsSSL3', 'on')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'sslVersionMin', b'TLS1.1'),
+                                                    (ldap.MOD_REPLACE, 'sslVersionMax', b'TLS1.2'),
+                                                    (ldap.MOD_REPLACE, 'nsSSL3', b'on')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -711,10 +709,10 @@ def test_47928_run_3(topology_st):
     _header(topology_st, 'Test Case 16 - nsSSL3: on; nsTLS1: off; sslVersionMin: TLS1.1; sslVersionMax: TLS1.2')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'sslVersionMin', 'TLS1.1'),
-                                                    (ldap.MOD_REPLACE, 'sslVersionMax', 'TLS1.2'),
-                                                    (ldap.MOD_REPLACE, 'nsSSL3', 'on'),
-                                                    (ldap.MOD_REPLACE, 'nsTLS1', 'off')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'sslVersionMin', b'TLS1.1'),
+                                                    (ldap.MOD_REPLACE, 'sslVersionMax', b'TLS1.2'),
+                                                    (ldap.MOD_REPLACE, 'nsSSL3', b'on'),
+                                                    (ldap.MOD_REPLACE, 'nsTLS1', b'off')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -759,7 +757,7 @@ def test_47838_run_last(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', None)])
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'all')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'all')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
diff --git a/dirsrvtests/tests/tickets/ticket47869MMR_test.py b/dirsrvtests/tests/tickets/ticket47869MMR_test.py
index 56b5273..ed6b3a2 100644
--- a/dirsrvtests/tests/tickets/ticket47869MMR_test.py
+++ b/dirsrvtests/tests/tickets/ticket47869MMR_test.py
@@ -14,6 +14,8 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_m2
+from lib389.replica import ReplicationManager
+from lib389.utils import *
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
@@ -26,6 +28,11 @@ BIND_NAME = 'bind_entry'
 BIND_DN = 'cn=%s, %s' % (BIND_NAME, SUFFIX)
 BIND_PW = 'password'
 
+def replication_check(topology_m2):
+    repl = ReplicationManager(SUFFIX)
+    master1 = topology_m2.ms["master1"]
+    master2 = topology_m2.ms["master2"]
+    return repl.test_replication(master1, master2)
 
 def test_ticket47869_init(topology_m2):
     """
@@ -34,7 +41,7 @@ def test_ticket47869_init(topology_m2):
 
     """
     # enable acl error logging
-    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', str(8192))]  # REPL
+    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', ensure_bytes(str(8192)))]  # REPL
     topology_m2.ms["master1"].modify_s(DN_CONFIG, mod)
     topology_m2.ms["master2"].modify_s(DN_CONFIG, mod)
 
@@ -45,21 +52,12 @@ def test_ticket47869_init(topology_m2):
         'sn': BIND_NAME,
         'cn': BIND_NAME,
         'userpassword': BIND_PW})))
-    loop = 0
-    ent = None
-    while loop <= 10:
-        try:
-            ent = topology_m2.ms["master2"].getEntry(BIND_DN, ldap.SCOPE_BASE, "(objectclass=*)")
-            break
-        except ldap.NO_SUCH_OBJECT:
-            time.sleep(1)
-            loop += 1
-    if ent is None:
-        assert False
-
+    replication_check(topology_m2)
+    ent = topology_m2.ms["master2"].getEntry(BIND_DN, ldap.SCOPE_BASE, "(objectclass=*)")
+    assert ent
     # keep anonymous ACI for use 'read-search' aci in SEARCH test
     ACI_ANONYMOUS = "(targetattr!=\"userPassword\")(version 3.0; acl \"Enable anonymous access\"; allow (read, search, compare) userdn=\"ldap:///anyone\";)"
-    mod = [(ldap.MOD_REPLACE, 'aci', ACI_ANONYMOUS)]
+    mod = [(ldap.MOD_REPLACE, 'aci', ensure_bytes(ACI_ANONYMOUS))]
     topology_m2.ms["master1"].modify_s(SUFFIX, mod)
     topology_m2.ms["master2"].modify_s(SUFFIX, mod)
 
@@ -71,18 +69,9 @@ def test_ticket47869_init(topology_m2):
                                                {'objectclass': "top person".split(),
                                                 'sn': name,
                                                 'cn': name})))
-        loop = 0
-        ent = None
-        while loop <= 10:
-            try:
-                ent = topology_m2.ms["master2"].getEntry(mydn, ldap.SCOPE_BASE, "(objectclass=*)")
-                break
-            except ldap.NO_SUCH_OBJECT:
-                time.sleep(1)
-                loop += 1
-        if ent is None:
-            assert False
-
+        replication_check(topology_m2)
+        ent = topology_m2.ms["master2"].getEntry(mydn, ldap.SCOPE_BASE, "(objectclass=*)")
+        assert ent
 
 def test_ticket47869_check(topology_m2):
     '''
diff --git a/dirsrvtests/tests/tickets/ticket47871_test.py b/dirsrvtests/tests/tickets/ticket47871_test.py
index 8d2a49e..0243157 100644
--- a/dirsrvtests/tests/tickets/ticket47871_test.py
+++ b/dirsrvtests/tests/tickets/ticket47871_test.py
@@ -41,8 +41,8 @@ def test_ticket47871_init(topology_m1c1):
         Initialize the test environment
     """
     topology_m1c1.ms["master1"].plugins.enable(name=PLUGIN_RETRO_CHANGELOG)
-    mod = [(ldap.MOD_REPLACE, 'nsslapd-changelogmaxage', "10s"),  # 10 second triming
-           (ldap.MOD_REPLACE, 'nsslapd-changelog-trim-interval', "5s")]
+    mod = [(ldap.MOD_REPLACE, 'nsslapd-changelogmaxage', b"10s"),  # 10 second triming
+           (ldap.MOD_REPLACE, 'nsslapd-changelog-trim-interval', b"5s")]
     topology_m1c1.ms["master1"].modify_s("cn=%s,%s" % (PLUGIN_RETRO_CHANGELOG, DN_PLUGIN), mod)
     # topology_m1c1.ms["master1"].plugins.enable(name=PLUGIN_MEMBER_OF)
     # topology_m1c1.ms["master1"].plugins.enable(name=PLUGIN_REFER_INTEGRITY)
diff --git a/dirsrvtests/tests/tickets/ticket47900_test.py b/dirsrvtests/tests/tickets/ticket47900_test.py
index ae3da98..8da5312 100644
--- a/dirsrvtests/tests/tickets/ticket47900_test.py
+++ b/dirsrvtests/tests/tickets/ticket47900_test.py
@@ -13,6 +13,7 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_st
+from lib389.utils import *
 
 log = logging.getLogger(__name__)
 
@@ -50,24 +51,20 @@ def test_ticket47900(topology_st):
     try:
         topology_st.standalone.add_s(entry)
     except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Unexpected result ' + e.message['desc'])
+        topology_st.standalone.log.error('Unexpected result ' + e.args[0]['desc'])
         assert False
         topology_st.standalone.log.error("Failed to add Password Administator %s, error: %s "
-                                         % (ADMIN_DN, e.message['desc']))
+                                         % (ADMIN_DN, e.args[0]['desc']))
         assert False
 
     topology_st.standalone.log.info("Configuring password policy...")
-    try:
-        topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-pwpolicy-local', 'on'),
-                                                    (ldap.MOD_REPLACE, 'passwordCheckSyntax', 'on'),
-                                                    (ldap.MOD_REPLACE, 'passwordMinCategories', '1'),
-                                                    (ldap.MOD_REPLACE, 'passwordMinTokenLength', '1'),
-                                                    (ldap.MOD_REPLACE, 'passwordExp', 'on'),
-                                                    (ldap.MOD_REPLACE, 'passwordMinDigits', '1'),
-                                                    (ldap.MOD_REPLACE, 'passwordMinSpecials', '1')])
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed configure password policy: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.config.replace_many(('nsslapd-pwpolicy-local', 'on'),
+                                               ('passwordCheckSyntax', 'on'),
+                                               ('passwordMinCategories', '1'),
+                                               ('passwordMinTokenLength', '1'),
+                                               ('passwordExp', 'on'),
+                                               ('passwordMinDigits', '1'),
+                                               ('passwordMinSpecials', '1'))
 
     #
     # Add an aci to allow everyone all access (just makes things easier)
@@ -79,22 +76,14 @@ def test_ticket47900(topology_st):
     ACI_ALLOW = "(version 3.0; acl \"Password Admin Access\"; allow (all) "
     ACI_SUBJECT = "(userdn = \"ldap:///anyone\");)"
     ACI_BODY = ACI_TARGET + ACI_TARGETATTR + ACI_ALLOW + ACI_SUBJECT
-    mod = [(ldap.MOD_ADD, 'aci', ACI_BODY)]
-    try:
-        topology_st.standalone.modify_s(SUFFIX, mod)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to add aci for password admin: ' + e.message['desc'])
-        assert False
+    mod = [(ldap.MOD_ADD, 'aci', ensure_bytes(ACI_BODY))]
+    topology_st.standalone.modify_s(SUFFIX, mod)
 
     #
     # Bind as the Password Admin
     #
     topology_st.standalone.log.info("Bind as the Password Administator (before activating)...")
-    try:
-        topology_st.standalone.simple_bind_s(ADMIN_DN, ADMIN_PWD)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to bind as the Password Admin: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.simple_bind_s(ADMIN_DN, ADMIN_PWD)
 
     #
     # Setup our test entry, and test password policy is working
@@ -118,7 +107,7 @@ def test_ticket47900(topology_st):
             # We failed as expected
             failed_as_expected = True
             topology_st.standalone.log.info('Add failed as expected: password (%s) result (%s)'
-                                            % (passwd, e.message['desc']))
+                                            % (passwd, e.args[0]['desc']))
 
         if not failed_as_expected:
             topology_st.standalone.log.error("We were incorrectly able to add an entry " +
@@ -132,25 +121,13 @@ def test_ticket47900(topology_st):
     topology_st.standalone.log.info("Activate the Password Administator...")
 
     # Bind as Root DN
-    try:
-        topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Root DN failed to authenticate: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
 
     # Update config
-    try:
-        topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'passwordAdminDN', ADMIN_DN)])
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to add password admin to config: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'passwordAdminDN', ensure_bytes(ADMIN_DN))])
 
     # Bind as Password Admin
-    try:
-        topology_st.standalone.simple_bind_s(ADMIN_DN, ADMIN_PWD)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to bind as the Password Admin: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.simple_bind_s(ADMIN_DN, ADMIN_PWD)
 
     #
     # Start adding entries with invalid passwords, delete the entry after each pass.
@@ -158,32 +135,17 @@ def test_ticket47900(topology_st):
     for passwd in INVALID_PWDS:
         entry.setValues('userpassword', passwd)
         topology_st.standalone.log.info("Create a regular user entry %s with password (%s)..." % (ENTRY_DN, passwd))
-        try:
-            topology_st.standalone.add_s(entry)
-        except ldap.LDAPError as e:
-            topology_st.standalone.log.error('Failed to add entry with password (%s) result (%s)'
-                                             % (passwd, e.message['desc']))
-            assert False
+        topology_st.standalone.add_s(entry)
 
         topology_st.standalone.log.info('Succesfully added entry (%s)' % ENTRY_DN)
 
         # Delete entry for the next pass
-        try:
-            topology_st.standalone.delete_s(ENTRY_DN)
-        except ldap.LDAPError as e:
-            topology_st.standalone.log.error('Failed to delete entry: %s' % (e.message['desc']))
-            assert False
-
+        topology_st.standalone.delete_s(ENTRY_DN)
     #
     # Add the entry for the next round of testing (modify password)
     #
     entry.setValues('userpassword', ADMIN_PWD)
-    try:
-        topology_st.standalone.add_s(entry)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to add entry with valid password (%s) result (%s)'
-                                         % (passwd, e.message['desc']))
-        assert False
+    topology_st.standalone.add_s(entry)
 
     #
     # Deactivate the password admin and make sure invalid password updates fail
@@ -191,25 +153,13 @@ def test_ticket47900(topology_st):
     topology_st.standalone.log.info("Deactivate Password Administator and try invalid password updates...")
 
     # Bind as root DN
-    try:
-        topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Root DN failed to authenticate: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
 
-    # Update config
-    try:
-        topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_DELETE, 'passwordAdminDN', None)])
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to remove password admin from config: ' + e.message['desc'])
-        assert False
+    # Update conf
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_DELETE, 'passwordAdminDN', None)])
 
     # Bind as Password Admin
-    try:
-        topology_st.standalone.simple_bind_s(ADMIN_DN, ADMIN_PWD)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to bind as the Password Admin: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.simple_bind_s(ADMIN_DN, ADMIN_PWD)
 
     #
     # Make invalid password updates that should fail
@@ -218,12 +168,12 @@ def test_ticket47900(topology_st):
         failed_as_expected = False
         entry.setValues('userpassword', passwd)
         try:
-            topology_st.standalone.modify_s(ENTRY_DN, [(ldap.MOD_REPLACE, 'userpassword', passwd)])
+            topology_st.standalone.modify_s(ENTRY_DN, [(ldap.MOD_REPLACE, 'userpassword', ensure_bytes(passwd))])
         except ldap.LDAPError as e:
             # We failed as expected
             failed_as_expected = True
             topology_st.standalone.log.info('Password update failed as expected: password (%s) result (%s)'
-                                            % (passwd, e.message['desc']))
+                                            % (passwd, e.args[0]['desc']))
 
         if not failed_as_expected:
             topology_st.standalone.log.error("We were incorrectly able to add an invalid password (%s)"
@@ -235,38 +185,21 @@ def test_ticket47900(topology_st):
     #
     topology_st.standalone.log.info("Activate Password Administator and try updates again...")
 
-    # Bind as root DN
-    try:
-        topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Root DN failed to authenticate: ' + e.message['desc'])
-        assert False
+    # Bind as root D
+    topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
 
     # Update config
-    try:
-        topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'passwordAdminDN', ADMIN_DN)])
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to add password admin to config: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'passwordAdminDN', ensure_bytes(ADMIN_DN))])
 
     # Bind as Password Admin
-    try:
-        topology_st.standalone.simple_bind_s(ADMIN_DN, ADMIN_PWD)
-    except ldap.LDAPError as e:
-        topology_st.standalone.log.error('Failed to bind as the Password Admin: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.simple_bind_s(ADMIN_DN, ADMIN_PWD)
 
     #
     # Make the same password updates, but this time they should succeed
     #
     for passwd in INVALID_PWDS:
         entry.setValues('userpassword', passwd)
-        try:
-            topology_st.standalone.modify_s(ENTRY_DN, [(ldap.MOD_REPLACE, 'userpassword', passwd)])
-        except ldap.LDAPError as e:
-            topology_st.standalone.log.error('Password update failed unexpectedly: password (%s) result (%s)'
-                                             % (passwd, e.message['desc']))
-            assert False
+        topology_st.standalone.modify_s(ENTRY_DN, [(ldap.MOD_REPLACE, 'userpassword', ensure_bytes(passwd))])
         topology_st.standalone.log.info('Password update succeeded (%s)' % passwd)
 
 
diff --git a/dirsrvtests/tests/tickets/ticket47910_test.py b/dirsrvtests/tests/tickets/ticket47910_test.py
index 5638419..35945d1 100644
--- a/dirsrvtests/tests/tickets/ticket47910_test.py
+++ b/dirsrvtests/tests/tickets/ticket47910_test.py
@@ -22,6 +22,8 @@ from lib389.utils import *
 
 # Skip on older versions
 pytestmark = pytest.mark.skipif(ds_is_older('1.3.4'), reason="Not implemented")
+
+
 @pytest.fixture(scope="module")
 def log_dir(topology_st):
     '''
@@ -60,8 +62,8 @@ def execute_logconv(inst, start_time_stamp, end_time_stamp, access_log):
     log.info(" ".join(cmd))
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     stdout, stderr = proc.communicate()
-    log.info("standard output" + stdout)
-    log.info("standard errors" + stderr)
+    log.info("standard output" + ensure_str(stdout))
+    log.info("standard errors" + ensure_str(stderr))
     return proc.returncode
 
 
@@ -151,8 +153,8 @@ def test_ticket47910_logconv_noaccesslogs(topology_st, log_dir):
     log.info(" ".join(cmd))
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     stdout, stderr = proc.communicate()
-    log.info("standard output" + stdout)
-    log.info("standard errors" + stderr)
+    log.info("standard output" + ensure_str(stdout))
+    log.info("standard errors" + ensure_str(stderr))
 
     assert proc.returncode == 1
 
diff --git a/dirsrvtests/tests/tickets/ticket47920_test.py b/dirsrvtests/tests/tickets/ticket47920_test.py
index 3db5d8d..2081100 100644
--- a/dirsrvtests/tests/tickets/ticket47920_test.py
+++ b/dirsrvtests/tests/tickets/ticket47920_test.py
@@ -105,11 +105,11 @@ def test_ticket47920_mod_readentry_ctrl(topology_st):
     topology_st.standalone.log.info("Check the initial value of the entry")
     ent = topology_st.standalone.getEntry(ACTIVE_USER_DN, ldap.SCOPE_BASE, "(objectclass=*)", ['description'])
     assert ent.hasAttr('description')
-    assert ent.getValue('description') == INITIAL_DESC
+    assert ensure_str(ent.getValue('description')) == INITIAL_DESC
 
     pr = PostReadControl(criticality=True, attrList=['cn', 'description'])
     _, _, _, resp_ctrls = topology_st.standalone.modify_ext_s(ACTIVE_USER_DN,
-                                                              [(ldap.MOD_REPLACE, 'description', [FINAL_DESC])],
+                                                              [(ldap.MOD_REPLACE, 'description', [ensure_bytes(FINAL_DESC)])],
                                                               serverctrls=[pr])
 
     assert resp_ctrls[0].dn == ACTIVE_USER_DN
@@ -119,7 +119,7 @@ def test_ticket47920_mod_readentry_ctrl(topology_st):
 
     ent = topology_st.standalone.getEntry(ACTIVE_USER_DN, ldap.SCOPE_BASE, "(objectclass=*)", ['description'])
     assert ent.hasAttr('description')
-    assert ent.getValue('description') == FINAL_DESC
+    assert ensure_str(ent.getValue('description')) == FINAL_DESC
 
 
 if __name__ == '__main__':
diff --git a/dirsrvtests/tests/tickets/ticket47921_test.py b/dirsrvtests/tests/tickets/ticket47921_test.py
index 2d2d35d..990abe7 100644
--- a/dirsrvtests/tests/tickets/ticket47921_test.py
+++ b/dirsrvtests/tests/tickets/ticket47921_test.py
@@ -25,79 +25,55 @@ def test_ticket47921(topology_st):
     USER_DN = 'uid=user,ou=people,' + DEFAULT_SUFFIX
 
     # Add COS definition
-    try:
-        topology_st.standalone.add_s(Entry((INDIRECT_COS_DN,
-                                            {
-                                                'objectclass': 'top cosSuperDefinition cosIndirectDefinition ldapSubEntry'.split(),
-                                                'cosIndirectSpecifier': 'manager',
-                                                'cosAttribute': 'roomnumber'
-                                                })))
-    except ldap.LDAPError as e:
-        log.fatal('Failed to add cos defintion, error: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.add_s(Entry((INDIRECT_COS_DN,
+                                        {
+                                            'objectclass': 'top cosSuperDefinition cosIndirectDefinition ldapSubEntry'.split(),
+                                            'cosIndirectSpecifier': 'manager',
+                                            'cosAttribute': 'roomnumber'
+                                            })))
 
     # Add manager entry
-    try:
-        topology_st.standalone.add_s(Entry((MANAGER_DN,
-                                            {'objectclass': 'top extensibleObject'.split(),
-                                             'uid': 'my manager',
-                                             'roomnumber': '1'
-                                             })))
-    except ldap.LDAPError as e:
-        log.fatal('Failed to add manager entry, error: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.add_s(Entry((MANAGER_DN,
+                                        {'objectclass': 'top extensibleObject'.split(),
+                                         'uid': 'my manager',
+                                         'roomnumber': '1'
+                                         })))
 
     # Add user entry
-    try:
-        topology_st.standalone.add_s(Entry((USER_DN,
-                                            {'objectclass': 'top person organizationalPerson inetorgperson'.split(),
-                                             'sn': 'last',
-                                             'cn': 'full',
-                                             'givenname': 'mark',
-                                             'uid': 'user',
-                                             'manager': MANAGER_DN
-                                             })))
-    except ldap.LDAPError as e:
-        log.fatal('Failed to add manager entry, error: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.add_s(Entry((USER_DN,
+                                        {'objectclass': 'top person organizationalPerson inetorgperson'.split(),
+                                         'sn': 'last',
+                                         'cn': 'full',
+                                         'givenname': 'mark',
+                                         'uid': 'user',
+                                         'manager': MANAGER_DN
+                                         })))
 
     # Test COS is working
-    try:
-        entry = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
-                                                "uid=user",
-                                                ['roomnumber'])
-        if entry:
-            if entry[0].getValue('roomnumber') != '1':
-                log.fatal('COS is not working.')
-                assert False
-        else:
-            log.fatal('Failed to find user entry')
+    entry = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
+                                            "uid=user",
+                                            ['roomnumber'])
+    if entry:
+        if ensure_str(entry[0].getValue('roomnumber')) != '1':
+            log.fatal('COS is not working.')
             assert False
-    except ldap.LDAPError as e:
-        log.error('Failed to search for user entry: ' + e.message['desc'])
+    else:
+        log.fatal('Failed to find user entry')
         assert False
 
     # Modify manager entry
-    try:
-        topology_st.standalone.modify_s(MANAGER_DN, [(ldap.MOD_REPLACE, 'roomnumber', '2')])
-    except ldap.LDAPError as e:
-        log.error('Failed to modify manager entry: ' + e.message['desc'])
-        assert False
+    topology_st.standalone.modify_s(MANAGER_DN, [(ldap.MOD_REPLACE, 'roomnumber', b'2')])
 
     # Confirm COS is returning the new value
-    try:
-        entry = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
-                                                "uid=user",
-                                                ['roomnumber'])
-        if entry:
-            if entry[0].getValue('roomnumber') != '2':
-                log.fatal('COS is not working after manager update.')
-                assert False
-        else:
-            log.fatal('Failed to find user entry')
+    entry = topology_st.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
+                                            "uid=user",
+                                            ['roomnumber'])
+    if entry:
+        if ensure_str(entry[0].getValue('roomnumber')) != '2':
+            log.fatal('COS is not working after manager update.')
             assert False
-    except ldap.LDAPError as e:
-        log.error('Failed to search for user entry: ' + e.message['desc'])
+    else:
+        log.fatal('Failed to find user entry')
         assert False
 
     log.info('Test complete')
diff --git a/dirsrvtests/tests/tickets/ticket47988_test.py b/dirsrvtests/tests/tickets/ticket47988_test.py
index ee5d16e..ed61a2a 100644
--- a/dirsrvtests/tests/tickets/ticket47988_test.py
+++ b/dirsrvtests/tests/tickets/ticket47988_test.py
@@ -23,6 +23,7 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_m2
+from lib389.utils import *
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
@@ -114,11 +115,11 @@ def test_ticket47988_init(topology_m2):
     _header(topology_m2, 'test_ticket47988_init')
 
     # enable acl error logging
-    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', str(8192))]  # REPL
+    mod = [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', ensure_bytes(str(8192)))]  # REPL
     topology_m2.ms["master1"].modify_s(DN_CONFIG, mod)
     topology_m2.ms["master2"].modify_s(DN_CONFIG, mod)
 
-    mod = [(ldap.MOD_REPLACE, 'nsslapd-accesslog-level', str(260))]  # Internal op
+    mod = [(ldap.MOD_REPLACE, 'nsslapd-accesslog-level', ensure_bytes(str(260)))]  # Internal op
     topology_m2.ms["master1"].modify_s(DN_CONFIG, mod)
     topology_m2.ms["master2"].modify_s(DN_CONFIG, mod)
 
@@ -164,7 +165,7 @@ def _do_update_schema(server, range=3999):
     NAME = 'thierry%s' % postfix
     value = '( %s NAME \'%s\' DESC \'Override for Group Attributes\' STRUCTURAL MUST ( cn ) MAY sn X-ORIGIN ( \'IPA v4.1.2\' \'user defined\' ) )' % (
     OID, NAME)
-    mod = [(ldap.MOD_ADD, 'objectclasses', value)]
+    mod = [(ldap.MOD_ADD, 'objectclasses', ensure_bytes(value))]
     server.modify_s('cn=schema', mod)
 
 
@@ -177,13 +178,13 @@ def _do_update_entry(supplier=None, consumer=None, attempts=10):
     assert (consumer)
     entryDN = "cn=%s0,%s" % (OTHER_NAME, SUFFIX)
     value = str(randint(100, 200))
-    mod = [(ldap.MOD_REPLACE, 'telephonenumber', value)]
+    mod = [(ldap.MOD_REPLACE, 'telephonenumber', ensure_bytes(value))]
     supplier.modify_s(entryDN, mod)
 
     loop = 0
     while loop <= attempts:
         ent = consumer.getEntry(entryDN, ldap.SCOPE_BASE, "(objectclass=*)", ['telephonenumber'])
-        read_val = ent.telephonenumber or "0"
+        read_val = ensure_str(ent.telephonenumber) or "0"
         if read_val == value:
             break
         # the expected value is not yet replicated. try again
diff --git a/dirsrvtests/tests/tickets/ticket48013_test.py b/dirsrvtests/tests/tickets/ticket48013_test.py
index f27e121..d5708f2 100644
--- a/dirsrvtests/tests/tickets/ticket48013_test.py
+++ b/dirsrvtests/tests/tickets/ticket48013_test.py
@@ -17,6 +17,7 @@ from lib389._constants import (PLUGIN_RETRO_CHANGELOG, DEFAULT_SUFFIX, DN_CONFIG
                               DN_DM, PASSWORD, PLUGIN_REPL_SYNC, HOST_STANDALONE,
                               PORT_STANDALONE)
 
+
 # Skip on older versions
 pytestmark = pytest.mark.skipif(ds_is_older('1.3.4'), reason="Not implemented")
 
@@ -47,9 +48,9 @@ def test_ticket48013(topology_st):
 
     # Enable dynamic plugins
     try:
-        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', 'on')])
+        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'on')])
     except ldap.LDAPError as e:
-        ldap.error('Failed to enable dynamic plugin!' + e.message['desc'])
+        log.error('Failed to enable dynamic plugin! {}'.format(e.args[0]['desc']))
         assert False
 
     # Enable retro changelog
@@ -67,7 +68,7 @@ def test_ticket48013(topology_st):
     try:
         ldap_connection.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        print('Login to LDAP server failed: %s' % e.message['desc'])
+        log.error('Login to LDAP server failed: {}'.format(e.args[0]['desc']))
         assert False
 
     # Test invalid cookies
@@ -79,7 +80,7 @@ def test_ticket48013(topology_st):
             log.fatal('Invalid cookie accepted!')
             assert False
         except Exception as e:
-            log.info('Invalid cookie correctly rejected: %s' % e.message['info'])
+            log.info('Invalid cookie correctly rejected: {}'.format(e.args[0]['info']))
             pass
 
     # Success
diff --git a/dirsrvtests/tests/tickets/ticket48026_test.py b/dirsrvtests/tests/tickets/ticket48026_test.py
index ae177ef..830beee 100644
--- a/dirsrvtests/tests/tickets/ticket48026_test.py
+++ b/dirsrvtests/tests/tickets/ticket48026_test.py
@@ -34,12 +34,12 @@ def test_ticket48026(topology_st):
     try:
         # This plugin enable / disable doesn't seem to create the nsslapd-pluginId correctly?
         inst.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config',
-                      [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', 'mail'),
+                      [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'mail'),
                        (ldap.MOD_ADD, 'uniqueness-attribute-name',
-                        'mailAlternateAddress'),
+                        b'mailAlternateAddress'),
                        ])
     except ldap.LDAPError as e:
-        log.fatal('test_ticket48026: Failed to configure plugin for "mail": error ' + e.message['desc'])
+        log.fatal('test_ticket48026: Failed to configure plugin for "mail": error {}'.format(e.args[0]['desc']))
         assert False
 
     inst.restart(timeout=30)
@@ -54,7 +54,7 @@ def test_ticket48026(topology_st):
                                      'mailAlternateAddress': 'user1@alt.example.com',
                                      'userpassword': 'password'})))
     except ldap.LDAPError as e:
-        log.fatal('test_ticket48026: Failed to add test user' + USER1_DN + ': error ' + e.message['desc'])
+        log.fatal('test_ticket48026: Failed to add test user' + USER1_DN + ': error {}'.format(e.args[0]['desc']))
         assert False
 
     try:
diff --git a/dirsrvtests/tests/tickets/ticket48109_test.py b/dirsrvtests/tests/tickets/ticket48109_test.py
index 5ef855d..6340e8e 100644
--- a/dirsrvtests/tests/tickets/ticket48109_test.py
+++ b/dirsrvtests/tests/tickets/ticket48109_test.py
@@ -31,12 +31,12 @@ def test_ticket48109(topology_st):
     # add substr setting to UID_INDEX
     try:
         topology_st.standalone.modify_s(UID_INDEX,
-                                        [(ldap.MOD_ADD, 'objectClass', 'extensibleObject'),
-                                         (ldap.MOD_ADD, 'nsIndexType', 'sub'),
-                                         (ldap.MOD_ADD, 'nsSubStrBegin', '2'),
-                                         (ldap.MOD_ADD, 'nsSubStrEnd', '2')])
+                                        [(ldap.MOD_ADD, 'objectClass', b'extensibleObject'),
+                                         (ldap.MOD_ADD, 'nsIndexType', b'sub'),
+                                         (ldap.MOD_ADD, 'nsSubStrBegin', b'2'),
+                                         (ldap.MOD_ADD, 'nsSubStrEnd', b'2')])
     except ldap.LDAPError as e:
-        log.error('Failed to add substr lengths: error ' + e.message['desc'])
+        log.error('Failed to add substr lengths: error {}'.format(e.args[0]['desc']))
         assert False
 
     # restart the server to apply the indexing
@@ -53,7 +53,7 @@ def test_ticket48109(topology_st):
             'givenname': 'a',
             'mail': UID})))
     except ldap.LDAPError as e:
-        log.error('Failed to add ' + USER_DN + ': error ' + e.message['desc'])
+        log.error('Failed to add ' + USER_DN + ': error {}'.format(e.args[0]['desc']))
         assert False
 
     entries = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(uid=a*)')
@@ -100,12 +100,12 @@ def test_ticket48109(topology_st):
     # clean up substr setting to UID_INDEX
     try:
         topology_st.standalone.modify_s(UID_INDEX,
-                                        [(ldap.MOD_DELETE, 'objectClass', 'extensibleObject'),
-                                         (ldap.MOD_DELETE, 'nsIndexType', 'sub'),
-                                         (ldap.MOD_DELETE, 'nsSubStrBegin', '2'),
-                                         (ldap.MOD_DELETE, 'nsSubStrEnd', '2')])
+                                        [(ldap.MOD_DELETE, 'objectClass', b'extensibleObject'),
+                                         (ldap.MOD_DELETE, 'nsIndexType', b'sub'),
+                                         (ldap.MOD_DELETE, 'nsSubStrBegin', b'2'),
+                                         (ldap.MOD_DELETE, 'nsSubStrEnd', b'2')])
     except ldap.LDAPError as e:
-        log.error('Failed to delete substr lengths: error ' + e.message['desc'])
+        log.error('Failed to delete substr lengths: error {}'.format(e.args[0]['desc']))
         assert False
 
     '''
@@ -118,11 +118,11 @@ def test_ticket48109(topology_st):
     # add substr setting to UID_INDEX
     try:
         topology_st.standalone.modify_s(UID_INDEX,
-                                        [(ldap.MOD_ADD, 'nsIndexType', 'sub'),
-                                         (ldap.MOD_ADD, 'nsMatchingRule', 'nssubstrbegin=2'),
-                                         (ldap.MOD_ADD, 'nsMatchingRule', 'nssubstrend=2')])
+                                        [(ldap.MOD_ADD, 'nsIndexType', b'sub'),
+                                         (ldap.MOD_ADD, 'nsMatchingRule', b'nssubstrbegin=2'),
+                                         (ldap.MOD_ADD, 'nsMatchingRule', b'nssubstrend=2')])
     except ldap.LDAPError as e:
-        log.error('Failed to add substr lengths: error ' + e.message['desc'])
+        log.error('Failed to add substr lengths: error {}'.format(e.args[0]['desc']))
         assert False
 
     # restart the server to apply the indexing
@@ -139,7 +139,7 @@ def test_ticket48109(topology_st):
             'givenname': 'b',
             'mail': UID})))
     except ldap.LDAPError as e:
-        log.error('Failed to add ' + USER_DN + ': error ' + e.message['desc'])
+        log.error('Failed to add ' + USER_DN + ': error {}'.format(e.args[0]['desc']))
         assert False
 
     entries = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(uid=b*)')
@@ -186,11 +186,11 @@ def test_ticket48109(topology_st):
     # clean up substr setting to UID_INDEX
     try:
         topology_st.standalone.modify_s(UID_INDEX,
-                                        [(ldap.MOD_DELETE, 'nsIndexType', 'sub'),
-                                         (ldap.MOD_DELETE, 'nsMatchingRule', 'nssubstrbegin=2'),
-                                         (ldap.MOD_DELETE, 'nsMatchingRule', 'nssubstrend=2')])
+                                        [(ldap.MOD_DELETE, 'nsIndexType', b'sub'),
+                                         (ldap.MOD_DELETE, 'nsMatchingRule', b'nssubstrbegin=2'),
+                                         (ldap.MOD_DELETE, 'nsMatchingRule', b'nssubstrend=2')])
     except ldap.LDAPError as e:
-        log.error('Failed to delete substr lengths: error ' + e.message['desc'])
+        log.error('Failed to delete substr lengths: error {}'.format(e.args[0]['desc']))
         assert False
 
     '''
@@ -208,14 +208,14 @@ def test_ticket48109(topology_st):
     # add substr setting to UID_INDEX
     try:
         topology_st.standalone.modify_s(UID_INDEX,
-                                        [(ldap.MOD_ADD, 'nsIndexType', 'sub'),
-                                         (ldap.MOD_ADD, 'nsMatchingRule', 'nssubstrbegin=3'),
-                                         (ldap.MOD_ADD, 'nsMatchingRule', 'nssubstrend=3'),
-                                         (ldap.MOD_ADD, 'objectClass', 'extensibleObject'),
-                                         (ldap.MOD_ADD, 'nsSubStrBegin', '2'),
-                                         (ldap.MOD_ADD, 'nsSubStrEnd', '2')])
+                                        [(ldap.MOD_ADD, 'nsIndexType', b'sub'),
+                                         (ldap.MOD_ADD, 'nsMatchingRule', b'nssubstrbegin=3'),
+                                         (ldap.MOD_ADD, 'nsMatchingRule', b'nssubstrend=3'),
+                                         (ldap.MOD_ADD, 'objectClass', b'extensibleObject'),
+                                         (ldap.MOD_ADD, 'nsSubStrBegin', b'2'),
+                                         (ldap.MOD_ADD, 'nsSubStrEnd', b'2')])
     except ldap.LDAPError as e:
-        log.error('Failed to add substr lengths: error ' + e.message['desc'])
+        log.error('Failed to add substr lengths: error {}'.format(e.args[0]['desc']))
         assert False
 
     # restart the server to apply the indexing
@@ -232,7 +232,7 @@ def test_ticket48109(topology_st):
             'givenname': 'c',
             'mail': UID})))
     except ldap.LDAPError as e:
-        log.error('Failed to add ' + USER_DN + ': error ' + e.message['desc'])
+        log.error('Failed to add ' + USER_DN + ': error {}'.format(e.args[0]['desc']))
         assert False
 
     entries = topology_st.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, '(uid=c*)')
@@ -317,14 +317,14 @@ def test_ticket48109(topology_st):
     # clean up substr setting to UID_INDEX
     try:
         topology_st.standalone.modify_s(UID_INDEX,
-                                        [(ldap.MOD_DELETE, 'nsIndexType', 'sub'),
-                                         (ldap.MOD_DELETE, 'nsMatchingRule', 'nssubstrbegin=3'),
-                                         (ldap.MOD_DELETE, 'nsMatchingRule', 'nssubstrend=3'),
-                                         (ldap.MOD_DELETE, 'objectClass', 'extensibleObject'),
-                                         (ldap.MOD_DELETE, 'nsSubStrBegin', '2'),
-                                         (ldap.MOD_DELETE, 'nsSubStrEnd', '2')])
+                                        [(ldap.MOD_DELETE, 'nsIndexType', b'sub'),
+                                         (ldap.MOD_DELETE, 'nsMatchingRule', b'nssubstrbegin=3'),
+                                         (ldap.MOD_DELETE, 'nsMatchingRule', b'nssubstrend=3'),
+                                         (ldap.MOD_DELETE, 'objectClass', b'extensibleObject'),
+                                         (ldap.MOD_DELETE, 'nsSubStrBegin', b'2'),
+                                         (ldap.MOD_DELETE, 'nsSubStrEnd', b'2')])
     except ldap.LDAPError as e:
-        log.error('Failed to delete substr lengths: error ' + e.message['desc'])
+        log.error('Failed to delete substr lengths: error {}'.format(e.args[0]['desc']))
         assert False
     log.info('Testcase PASSED')
 
diff --git a/dirsrvtests/tests/tickets/ticket48170_test.py b/dirsrvtests/tests/tickets/ticket48170_test.py
index adfbcb8..8547989 100644
--- a/dirsrvtests/tests/tickets/ticket48170_test.py
+++ b/dirsrvtests/tests/tickets/ticket48170_test.py
@@ -22,7 +22,7 @@ def test_ticket48170(topology_st):
     INDEX_DN = 'cn=cn,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config'
     REJECTED = False
     try:
-        topology_st.standalone.modify_s(INDEX_DN, [(ldap.MOD_ADD, 'nsINdexType', 'eq,pres')])
+        topology_st.standalone.modify_s(INDEX_DN, [(ldap.MOD_ADD, 'nsINdexType', b'eq,pres')])
     except ldap.UNWILLING_TO_PERFORM:
         log.info('Index update correctly rejected')
         REJECTED = True
diff --git a/dirsrvtests/tests/tickets/ticket48194_test.py b/dirsrvtests/tests/tickets/ticket48194_test.py
index 6879eec..b94b726 100644
--- a/dirsrvtests/tests/tickets/ticket48194_test.py
+++ b/dirsrvtests/tests/tickets/ticket48194_test.py
@@ -15,6 +15,7 @@ import pytest
 from lib389 import Entry
 from lib389._constants import *
 from lib389.topologies import topology_st
+from lib389.nss_ssl import NssSsl
 
 log = logging.getLogger(__name__)
 
@@ -26,7 +27,7 @@ pytestmark = pytest.mark.skipif(ds_is_older('1.3.4'), reason="Not implemented")
 ENCRYPTION_DN = 'cn=encryption,%s' % CONFIG_DN
 RSA = 'RSA'
 RSA_DN = 'cn=%s,%s' % (RSA, ENCRYPTION_DN)
-LDAPSPORT = str(DEFAULT_SECURE_PORT)
+LDAPSPORT = str(SECUREPORT_STANDALONE)
 SERVERCERT = 'Server-Cert'
 plus_all_ecount = 0
 plus_all_dcount = 0
@@ -47,21 +48,22 @@ def test_init(topology_st):
     """
     _header(topology_st, 'Testing Ticket 48194 - harden the list of ciphers available by default')
 
-    topology_st.standalone.nss_ssl.reinit()
-    topology_st.standalone.nss_ssl.create_rsa_ca()
-    topology_st.standalone.nss_ssl.create_rsa_key_and_cert()
+    nss_ssl = NssSsl(dbpath=topology_st.standalone.get_cert_dir())
+    nss_ssl.reinit()
+    nss_ssl.create_rsa_ca()
+    nss_ssl.create_rsa_key_and_cert()
 
     log.info("\n######################### enable SSL in the directory server with all ciphers ######################\n")
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3', 'off'),
-                                                    (ldap.MOD_REPLACE, 'nsTLS1', 'on'),
-                                                    (ldap.MOD_REPLACE, 'nsSSLClientAuth', 'allowed'),
-                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', 'on'),
-                                                    (ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+all')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3', b'off'),
+                                                    (ldap.MOD_REPLACE, 'nsTLS1', b'on'),
+                                                    (ldap.MOD_REPLACE, 'nsSSLClientAuth', b'allowed'),
+                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', b'on'),
+                                                    (ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'+all')])
 
-    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-security', 'on'),
-                                                (ldap.MOD_REPLACE, 'nsslapd-ssl-check-hostname', 'off'),
-                                                (ldap.MOD_REPLACE, 'nsslapd-secureport', LDAPSPORT)])
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-security', b'on'),
+                                                (ldap.MOD_REPLACE, 'nsslapd-ssl-check-hostname', b'off'),
+                                                (ldap.MOD_REPLACE, 'nsslapd-secureport', ensure_bytes(LDAPSPORT))])
 
     topology_st.standalone.add_s(Entry((RSA_DN, {'objectclass': "top nsEncryptionModule".split(),
                                                  'cn': RSA,
@@ -95,18 +97,18 @@ def connectWithOpenssl(topology_st, cipher, expect):
 
     while True:
         l = proc.stdout.readline()
-        if l == "":
+        if l == b"":
             break
-        if 'Cipher is' in l:
+        if b'Cipher is' in l:
             log.info("Found: %s", l)
             if expect:
-                if '(NONE)' in l:
+                if b'(NONE)' in l:
                     assert False
                 else:
                     proc.stdin.close()
                     assert True
             else:
-                if '(NONE)' in l:
+                if b'(NONE)' in l:
                     assert True
                 else:
                     proc.stdin.close()
@@ -122,7 +124,7 @@ def test_run_0(topology_st):
     _header(topology_st, 'Test Case 1 - Check the ciphers availability for "+all"; allowWeakCipher: on')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')])
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'64')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.restart(timeout=120)
@@ -140,7 +142,7 @@ def test_run_1(topology_st):
     _header(topology_st, 'Test Case 2 - Check the ciphers availability for "+all" with default allowWeakCiphers')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', '64')])
+    topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', b'64')])
     # Make sure allowWeakCipher is not set.
     topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'allowWeakCipher', None)])
 
@@ -166,7 +168,7 @@ def test_run_2(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     topology_st.standalone.modify_s(ENCRYPTION_DN,
-                                    [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+rsa_aes_128_sha,+rsa_aes_256_sha')])
+                                    [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'+rsa_aes_128_sha,+rsa_aes_256_sha')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -190,7 +192,7 @@ def test_run_3(topology_st):
     _header(topology_st, 'Test Case 4 - Check the ciphers availability for "-all"')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '-all')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'-all')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -212,7 +214,7 @@ def test_run_4(topology_st):
     _header(topology_st, 'Test Case 5 - Check no nsSSL3Ciphers (-all) with default allowWeakCipher')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'nsSSL3Ciphers', '-all')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_DELETE, 'nsSSL3Ciphers', b'-all')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -234,7 +236,7 @@ def test_run_5(topology_st):
     _header(topology_st, 'Test Case 6 - Check default nsSSL3Ciphers (default setting) with default allowWeakCipher')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'default')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'default')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -258,7 +260,7 @@ def test_run_6(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     topology_st.standalone.modify_s(ENCRYPTION_DN,
-                                    [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+all,-TLS_RSA_WITH_AES_256_CBC_SHA256')])
+                                    [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'+all,-TLS_RSA_WITH_AES_256_CBC_SHA256')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -280,8 +282,8 @@ def test_run_8(topology_st):
     _header(topology_st, 'Test Case 9 - Check default nsSSL3Ciphers (default setting + allowWeakCipher: off)')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', 'default'),
-                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', 'off')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'default'),
+                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', b'off')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
@@ -306,7 +308,7 @@ def test_run_9(topology_st):
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', None),
-                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', 'on')])
+                                                    (ldap.MOD_REPLACE, 'allowWeakCipher', b'on')])
     topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'nsslapd-errorlog-level', None)])
 
     log.info("\n######################### Restarting the server ######################\n")
@@ -328,7 +330,7 @@ def test_run_11(topology_st):
     _header(topology_st, 'Test Case 12 - Check nsSSL3Ciphers: +fortezza, which is not supported')
 
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
-    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', '+fortezza')])
+    topology_st.standalone.modify_s(ENCRYPTION_DN, [(ldap.MOD_REPLACE, 'nsSSL3Ciphers', b'+fortezza')])
 
     log.info("\n######################### Restarting the server ######################\n")
     topology_st.standalone.stop(timeout=10)
diff --git a/dirsrvtests/tests/tickets/ticket48212_test.py b/dirsrvtests/tests/tickets/ticket48212_test.py
index 2483953..2fb1007 100644
--- a/dirsrvtests/tests/tickets/ticket48212_test.py
+++ b/dirsrvtests/tests/tickets/ticket48212_test.py
@@ -15,7 +15,7 @@ UIDNUMBERDN = "cn=uidnumber,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=
 
 def runDbVerify(topology_st):
     topology_st.standalone.log.info("\n\n	+++++ dbverify +++++\n")
-    sbin_dir = get_sbin_dir(prefix=topology_st.standalone.prefix)
+    sbin_dir = get_sbin_dir()
     dbverifyCMD = sbin_dir + "/dbverify -Z " + topology_st.standalone.serverid + " -V"
     dbverifyOUT = os.popen(dbverifyCMD, "r")
     topology_st.standalone.log.info("Running %s" % dbverifyCMD)
@@ -69,7 +69,7 @@ def test_ticket48212(topology_st):
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
 
     data_dir_path = topology_st.standalone.getDir(__file__, DATA_DIR)
-    ldif_file = data_dir_path + "ticket48212/" + _MYLDIF
+    ldif_file = f"{data_dir_path}ticket48212/{_MYLDIF}"
     try:
         ldif_dir = topology_st.standalone.get_ldif_dir()
         shutil.copy(ldif_file, ldif_dir)
@@ -103,7 +103,7 @@ def test_ticket48212(topology_st):
 
     topology_st.standalone.log.info("\n\n######################### Add nsMatchingRule ######################\n")
     try:
-        topology_st.standalone.modify_s(UIDNUMBERDN, [(ldap.MOD_ADD, 'nsMatchingRule', 'integerOrderingMatch')])
+        topology_st.standalone.modify_s(UIDNUMBERDN, [(ldap.MOD_ADD, 'nsMatchingRule', b'integerOrderingMatch')])
     except ValueError:
         topology_st.standalone.log.fatal("modify_s failed: %s", ValueError)
 
@@ -114,7 +114,7 @@ def test_ticket48212(topology_st):
 
     topology_st.standalone.log.info("\n\n######################### Delete nsMatchingRule ######################\n")
     try:
-        topology_st.standalone.modify_s(UIDNUMBERDN, [(ldap.MOD_DELETE, 'nsMatchingRule', 'integerOrderingMatch')])
+        topology_st.standalone.modify_s(UIDNUMBERDN, [(ldap.MOD_DELETE, 'nsMatchingRule', b'integerOrderingMatch')])
     except ValueError:
         topology_st.standalone.log.fatal("modify_s failed: %s", ValueError)
 
diff --git a/dirsrvtests/tests/tickets/ticket48214_test.py b/dirsrvtests/tests/tickets/ticket48214_test.py
index 9b95862..2f380fd 100644
--- a/dirsrvtests/tests/tickets/ticket48214_test.py
+++ b/dirsrvtests/tests/tickets/ticket48214_test.py
@@ -85,12 +85,12 @@ def test_ticket48214_run(topology_st):
     checkMaxBerSize(topology_st)
 
     topology_st.standalone.log.info("\n\n######################### Add nsslapd-maxbersize: 0 ######################\n")
-    topology_st.standalone.modify_s('cn=config', [(ldap.MOD_REPLACE, 'nsslapd-maxbersize', '0')])
+    topology_st.standalone.modify_s('cn=config', [(ldap.MOD_REPLACE, 'nsslapd-maxbersize', b'0')])
     checkMaxBerSize(topology_st)
 
     topology_st.standalone.log.info(
         "\n\n######################### Add nsslapd-maxbersize: 10000 ######################\n")
-    topology_st.standalone.modify_s('cn=config', [(ldap.MOD_REPLACE, 'nsslapd-maxbersize', '10000')])
+    topology_st.standalone.modify_s('cn=config', [(ldap.MOD_REPLACE, 'nsslapd-maxbersize', b'10000')])
     checkMaxBerSize(topology_st)
 
     topology_st.standalone.log.info("ticket48214 was successfully verified.")
diff --git a/dirsrvtests/tests/tickets/ticket48233_test.py b/dirsrvtests/tests/tickets/ticket48233_test.py
index 4abeddd..3c29633 100644
--- a/dirsrvtests/tests/tickets/ticket48233_test.py
+++ b/dirsrvtests/tests/tickets/ticket48233_test.py
@@ -19,9 +19,9 @@ def test_ticket48233(topology_st):
                 '(userdn = "ldap:///anyone") and (ip="127.0.0.1");)')
 
     try:
-        topology_st.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', aci_text)])
+        topology_st.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', ensure_bytes(aci_text))])
     except ldap.LDAPError as e:
-        log.error('Failed to add aci: (%s) error %s' % (aci_text, e.message['desc']))
+        log.error('Failed to add aci: ({}) error {}'.format(aci_text,e.args[0]['desc']))
         assert False
     time.sleep(1)
 
@@ -29,7 +29,7 @@ def test_ticket48233(topology_st):
     try:
         topology_st.standalone.simple_bind_s("", "")
     except ldap.LDAPError as e:
-        log.error('Failed to anonymously bind -error %s' % (e.message['desc']))
+        log.error('Failed to anonymously bind -error {}'.format(e.args[0]['desc']))
         assert False
 
     try:
diff --git a/dirsrvtests/tests/tickets/ticket48370_test.py b/dirsrvtests/tests/tickets/ticket48370_test.py
index b8ae106..df55a17 100644
--- a/dirsrvtests/tests/tickets/ticket48370_test.py
+++ b/dirsrvtests/tests/tickets/ticket48370_test.py
@@ -43,12 +43,12 @@ def test_ticket48370(topology_st):
     try:
         topology_st.standalone.modify_s(DN, [(ldap.MOD_DELETE,
                                               'mail',
-                                              'user0099@dev.null'),
+                                              b'user0099@dev.null'),
                                              (ldap.MOD_DELETE,
                                               'mail',
-                                              'alias@dev.null'),
+                                              b'alias@dev.null'),
                                              (ldap.MOD_ADD,
-                                              'mail', 'user0099@dev.null')])
+                                              'mail', b'user0099@dev.null')])
     except ldap.LDAPError as e:
         log.fatal('Failedto modify user: ' + str(e))
         assert False
@@ -87,10 +87,10 @@ def test_ticket48370(topology_st):
     try:
         topology_st.standalone.modify_s(DN, [(ldap.MOD_DELETE,
                                               'mail',
-                                              'user0099@dev.null'),
+                                              b'user0099@dev.null'),
                                              (ldap.MOD_DELETE,
                                               'mail',
-                                              'user0099@redhat.com')
+                                              b'user0099@redhat.com')
                                              ])
     except ldap.LDAPError as e:
         log.fatal('Failed to modify user: ' + str(e))
@@ -132,8 +132,8 @@ def test_ticket48370(topology_st):
     try:
         topology_st.standalone.modify_s(DN, [(ldap.MOD_ADD,
                                               'mail',
-                                              ['user0099@dev.null',
-                                               'alias@dev.null'])])
+                                              [b'user0099@dev.null',
+                                               b'alias@dev.null'])])
     except ldap.LDAPError as e:
         log.fatal('Failedto modify user: ' + str(e))
         assert False
@@ -144,12 +144,12 @@ def test_ticket48370(topology_st):
     try:
         topology_st.standalone.modify_s(DN, [(ldap.MOD_DELETE,
                                               'mail',
-                                              'alias@dev.null'),
+                                              b'alias@dev.null'),
                                              (ldap.MOD_DELETE,
                                               'mail',
-                                              'user0099@dev.null'),
+                                              b'user0099@dev.null'),
                                              (ldap.MOD_ADD,
-                                              'mail', 'user0099@dev.null')])
+                                              'mail', b'user0099@dev.null')])
     except ldap.LDAPError as e:
         log.fatal('Failedto modify user: ' + str(e))
         assert False
diff --git a/dirsrvtests/tests/tickets/ticket48383_test.py b/dirsrvtests/tests/tickets/ticket48383_test.py
index a6dfbed..f681b83 100644
--- a/dirsrvtests/tests/tickets/ticket48383_test.py
+++ b/dirsrvtests/tests/tickets/ticket48383_test.py
@@ -30,7 +30,7 @@ def test_ticket48383(topology_st):
     # Create some stupid huge objects / attributes in DS.
     # seeAlso is indexed by default. Lets do that!
     # This will take a while ...
-    data = [random.choice(string.letters) for x in xrange(10000000)]
+    data = [random.choice(string.ascii_letters) for x in range(10000000)]
     s = "".join(data)
 
     # This was here for an iteration test.
@@ -50,18 +50,14 @@ def test_ticket48383(topology_st):
         'padding': padding,
     }))
 
-    try:
-        topology_st.standalone.add_s(user)
-    except ldap.LDAPError as e:
-        log.fatal('test 48383: Failed to user%s: error %s ' % (i, e.message['desc']))
-        assert False
+    topology_st.standalone.add_s(user)
 
     # Set the dbsize really low.
     try:
         topology_st.standalone.modify_s(DEFAULT_BENAME, [(ldap.MOD_REPLACE,
-                                                          'nsslapd-cachememsize', '1')])
+                                                          'nsslapd-cachememsize', b'1')])
     except ldap.LDAPError as e:
-        log.fatal('Failed to change nsslapd-cachememsize ' + e.message['desc'])
+        log.fatal('Failed to change nsslapd-cachememsize {}'.format(e.args[0]['desc']))
 
     ## Does ds try and set a minimum possible value for this?
     ## Yes: [16/Feb/2016:16:39:18 +1000] - WARNING: cache too small, increasing to 500K bytes

