Add tox tests and fixes for Python 2/3 compatibility.