diff --git a/src/mod_sso/test/httpd_integration_test.py b/src/mod_sso/test/httpd_integration_test.py
index e81c2e5ce3f5b0ce68fb6acbdbdf3404c22318f4..08ba77047c9b78f17e8f49a8e566b3cb647c52e9 100755
--- a/src/mod_sso/test/httpd_integration_test.py
+++ b/src/mod_sso/test/httpd_integration_test.py
@@ -115,7 +115,7 @@ def mkcookie(tkt):
 class HttpdKeyLoadingTest(unittest.TestCase):
 
     def test_key_with_null_byte(self):
-        has_null_byte = lambda s: '\0' in s
+        has_null_byte = lambda s: 0 in s
 
         public = ''
         while not has_null_byte(public):
@@ -297,7 +297,8 @@ class HttpdIntegrationTestBase(unittest.TestCase):
         set_cookie_hdr = resp.getheader("Set-Cookie")
         self.assertTrue(set_cookie_hdr)
         cookies.load(set_cookie_hdr)
-        self.assertEquals(tkt, cookies['SSO_test'].value)
+        self.assertEquals(tkt, cookies['SSO_test'].value,
+                          "set-cookie: %s" % set_cookie_hdr)
         conn.close()
 
         # Make the original request again.
@@ -354,7 +355,8 @@ class HttpdIntegrationTest(HttpdIntegrationTestBase):
         set_cookie_hdr = resp.getheader("Set-Cookie")
         self.assertTrue(set_cookie_hdr)
         cookies.load(set_cookie_hdr)
-        self.assertEquals(tkt, cookies['SSO_test'].value)
+        self.assertEquals(tkt, cookies['SSO_test'].value,
+                          "set-cookie: %s" % set_cookie_hdr)
         conn.close()
 
     def test_sso_logout(self):
@@ -391,7 +393,7 @@ class HttpdIntegrationTestWithNonces(HttpdIntegrationTestBase):
         self.assertTrue(b"REMOTE_USER=testuser" in body)
         self.assertTrue(b"SSO_USER=testuser" in body)
         self.assertTrue(b"SSO_SERVICE=service.example.com/" in body)
-        self.assertTrue(b("SSO_TICKET=" + tkt.encode('utf-8')) in body)
+        self.assertTrue((b"SSO_TICKET=" + tkt.encode('utf-8')) in body)
         self.assertTrue(b"SSO_NONCE=NONCE1" in body)
 
     def test_login_workflow(self):
@@ -410,7 +412,7 @@ class WebmailIntegrationTestWithNonces(HttpdIntegrationTestBase):
     CONFIG = 'test-httpd-2.4-webmail.conf'
 
     def setUp(self):
-        with open('session.key', 'w') as fd:
+        with open('session.key', 'wb') as fd:
             fd.write(os.urandom(32))
         HttpdIntegrationTestBase.setUp(self)