Parellelized testing. Caught a lot of bugs.
diff --git a/tests/test_bigfile.py b/tests/test_bigfile.py
index 974da8b..9e3a864 100644
--- a/tests/test_bigfile.py
+++ b/tests/test_bigfile.py
@@ -1,4 +1,4 @@
-'''Tests block operations.'''
+"""Tests block operations."""
 from rsa._compat import b
 
 try:
diff --git a/tests/test_common.py b/tests/test_common.py
new file mode 100644
index 0000000..bad24f8
--- /dev/null
+++ b/tests/test_common.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import unittest2
+import struct
+from rsa._compat import byte, b
+from rsa.common import byte_size, bit_size, _bit_size
+
+
+class Test_byte(unittest2.TestCase):
+    def test_values(self):
+        self.assertEqual(byte(0), b('\x00'))
+        self.assertEqual(byte(255), b('\xff'))
+
+    def test_struct_error_when_out_of_bounds(self):
+        self.assertRaises(struct.error, byte, 256)
+        self.assertRaises(struct.error, byte, -1)
+
+
+class Test_byte_size(unittest2.TestCase):
+    def test_values(self):
+        self.assertEqual(byte_size(1 << 1023), 128)
+        self.assertEqual(byte_size((1 << 1024) - 1), 128)
+        self.assertEqual(byte_size(1 << 1024), 129)
+
+    def test_zero(self):
+        self.assertEqual(byte_size(0), 0)
+
+    def test_bad_type(self):
+        self.assertRaises(TypeError, byte_size, [])
+        self.assertRaises(TypeError, byte_size, ())
+        self.assertRaises(TypeError, byte_size, dict())
+        self.assertRaises(TypeError, byte_size, "")
+        self.assertRaises(TypeError, byte_size, None)
+
+class Test_bit_size(unittest2.TestCase):
+    def test_values(self):
+        self.assertEqual(bit_size(1023), 10)
+        self.assertEqual(bit_size(1024), 11)
+        self.assertEqual(bit_size(1025), 11)
+        self.assertEqual(bit_size(1 << 1024), 1025)
+        self.assertEqual(bit_size((1 << 1024) + 1), 1025)
+        self.assertEqual(bit_size((1 << 1024) - 1), 1024)
+
+        self.assertEqual(_bit_size(1023), 10)
+        self.assertEqual(_bit_size(1024), 11)
+        self.assertEqual(_bit_size(1025), 11)
+        self.assertEqual(_bit_size(1 << 1024), 1025)
+        self.assertEqual(_bit_size((1 << 1024) + 1), 1025)
+        self.assertEqual(_bit_size((1 << 1024) - 1), 1024)
diff --git a/tests/test_integers.py b/tests/test_integers.py
index 0a712aa..c73be2c 100644
--- a/tests/test_integers.py
+++ b/tests/test_integers.py
@@ -1,4 +1,4 @@
-'''Tests integer operations.'''
+"""Tests integer operations."""
 
 import unittest2
 
diff --git a/tests/test_load_save_keys.py b/tests/test_load_save_keys.py
index fc1a1aa..30bbb21 100644
--- a/tests/test_load_save_keys.py
+++ b/tests/test_load_save_keys.py
@@ -1,4 +1,4 @@
-'''Unittest for saving and loading keys.'''
+"""Unittest for saving and loading keys."""
 
 import base64
 import unittest2
@@ -12,7 +12,7 @@
 B64PUB_DER = b('MAwCBQDeKYlRAgMBAAE=')
 PUBLIC_DER = base64.decodestring(B64PUB_DER)
 
-PRIVATE_PEM = b('''
+PRIVATE_PEM = b("""
 -----BEGIN CONFUSING STUFF-----
 Cruft before the key
 
@@ -24,15 +24,15 @@
 
 Stuff after the key
 -----END CONFUSING STUFF-----
-''' % B64PRIV_DER.decode("utf-8"))
+""" % B64PRIV_DER.decode("utf-8"))
 
-CLEAN_PRIVATE_PEM = b('''\
+CLEAN_PRIVATE_PEM = b("""\
 -----BEGIN RSA PRIVATE KEY-----
 %s
 -----END RSA PRIVATE KEY-----
-''' % B64PRIV_DER.decode("utf-8"))
+""" % B64PRIV_DER.decode("utf-8"))
 
-PUBLIC_PEM = b('''
+PUBLIC_PEM = b("""
 -----BEGIN CONFUSING STUFF-----
 Cruft before the key
 
@@ -44,20 +44,20 @@
 
 Stuff after the key
 -----END CONFUSING STUFF-----
-''' % B64PUB_DER.decode("utf-8"))
+""" % B64PUB_DER.decode("utf-8"))
 
-CLEAN_PUBLIC_PEM = b('''\
+CLEAN_PUBLIC_PEM = b("""\
 -----BEGIN RSA PUBLIC KEY-----
 %s
 -----END RSA PUBLIC KEY-----
-''' % B64PUB_DER.decode("utf-8"))
+""" % B64PUB_DER.decode("utf-8"))
 
 
 class DerTest(unittest2.TestCase):
-    '''Test saving and loading DER keys.'''
+    """Test saving and loading DER keys."""
 
     def test_load_private_key(self):
-        '''Test loading private DER keys.'''
+        """Test loading private DER keys."""
 
         key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_DER, 'DER')
         expected = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
@@ -65,7 +65,7 @@
         self.assertEqual(expected, key)
 
     def test_save_private_key(self):
-        '''Test saving private DER keys.'''
+        """Test saving private DER keys."""
 
         key = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
         der = key.save_pkcs1('DER')
@@ -73,7 +73,7 @@
         self.assertEqual(PRIVATE_DER, der)
 
     def test_load_public_key(self):
-        '''Test loading public DER keys.'''
+        """Test loading public DER keys."""
 
         key = rsa.key.PublicKey.load_pkcs1(PUBLIC_DER, 'DER')
         expected = rsa.key.PublicKey(3727264081, 65537)
@@ -81,7 +81,7 @@
         self.assertEqual(expected, key)
 
     def test_save_public_key(self):
-        '''Test saving public DER keys.'''
+        """Test saving public DER keys."""
 
         key = rsa.key.PublicKey(3727264081, 65537)
         der = key.save_pkcs1('DER')
@@ -89,11 +89,11 @@
         self.assertEqual(PUBLIC_DER, der)
 
 class PemTest(unittest2.TestCase):
-    '''Test saving and loading PEM keys.'''
+    """Test saving and loading PEM keys."""
 
 
     def test_load_private_key(self):
-        '''Test loading private PEM files.'''
+        """Test loading private PEM files."""
 
         key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_PEM, 'PEM')
         expected = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
@@ -101,7 +101,7 @@
         self.assertEqual(expected, key)
 
     def test_save_private_key(self):
-        '''Test saving private PEM files.'''
+        """Test saving private PEM files."""
 
         key = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
         pem = key.save_pkcs1('PEM')
@@ -109,7 +109,7 @@
         self.assertEqual(CLEAN_PRIVATE_PEM, pem)
 
     def test_load_public_key(self):
-        '''Test loading public PEM files.'''
+        """Test loading public PEM files."""
 
         key = rsa.key.PublicKey.load_pkcs1(PUBLIC_PEM, 'PEM')
         expected = rsa.key.PublicKey(3727264081, 65537)
@@ -117,7 +117,7 @@
         self.assertEqual(expected, key)
 
     def test_save_public_key(self):
-        '''Test saving public PEM files.'''
+        """Test saving public PEM files."""
 
         key = rsa.key.PublicKey(3727264081, 65537)
         pem = key.save_pkcs1('PEM')
diff --git a/tests/test_pkcs1.py b/tests/test_pkcs1.py
index 55098e2..5d2fbad 100644
--- a/tests/test_pkcs1.py
+++ b/tests/test_pkcs1.py
@@ -1,4 +1,4 @@
-'''Tests string operations.'''
+"""Tests string operations."""
 
 import struct
 import unittest2
@@ -40,9 +40,9 @@
                           self.priv)
 
     def test_randomness(self):
-        '''Encrypting the same message twice should result in different
+        """Encrypting the same message twice should result in different
         cryptos.
-        '''
+        """
         
         message = struct.pack('>IIII', 0, 0, 0, 1)
         encrypted1 = pkcs1.encrypt(message, self.pub)
@@ -56,7 +56,7 @@
         (self.pub, self.priv) = rsa.newkeys(512)
 
     def test_sign_verify(self):
-        '''Test happy flow of sign and verify'''
+        """Test happy flow of sign and verify"""
         
         message = b('je moeder')
         print("\tMessage:   %r" % message)
@@ -67,14 +67,14 @@
         pkcs1.verify(message, signature, self.pub)
 
     def test_alter_message(self):
-        '''Altering the message should let the verification fail.'''
+        """Altering the message should let the verification fail."""
         
         signature = pkcs1.sign(b('je moeder'), self.priv, 'SHA-256')
         self.assertRaises(pkcs1.VerificationError, pkcs1.verify,
                           b('mijn moeder'), signature, self.pub)
 
     def test_sign_different_key(self):
-        '''Signing with another key should let the verification fail.'''
+        """Signing with another key should let the verification fail."""
         
         (otherpub, _) = rsa.newkeys(512)
         
@@ -84,7 +84,7 @@
                           message, signature, otherpub)
 
     def test_multiple_signings(self):
-        '''Signing the same message twice should return the same signatures.'''
+        """Signing the same message twice should return the same signatures."""
         
         message = struct.pack('>IIII', 0, 0, 0, 1)
         signature1 = pkcs1.sign(message, self.priv, 'SHA-1')
diff --git a/tests/test_strings.py b/tests/test_strings.py
index 001456d..a2f9483 100644
--- a/tests/test_strings.py
+++ b/tests/test_strings.py
@@ -1,4 +1,4 @@
-'''Tests string operations.'''
+"""Tests string operations."""
 
 from __future__ import absolute_import
 
diff --git a/tests/test_varblock.py b/tests/test_varblock.py
index 24ea50f..d6465ed 100644
--- a/tests/test_varblock.py
+++ b/tests/test_varblock.py
@@ -1,4 +1,4 @@
-'''Tests varblock operations.'''
+"""Tests varblock operations."""
 
 
 try: