Fix tests for Python 2.x

This branch reworks some of the tests and makes some code changes to make the tests run on both Python 2.6 and 2.7.

It also includes a `tox.ini` file to run tests for different Python versions using tox environments.