Make tests pass on Python 3 too

Does some mostly mechanical porting and lays ground for moving CI to py.test including local testing using tox.