Add pytest and tox to testing pipeline

This is the first step towards Python 3 compatibility.
Use range instead of xrange for Python 3
Avoid dict.iteritems()
Fix relative imports
Add division and absolute_import
Work around Python 3's dict methods being iters

Implicitly take advantage of them in one case, use a less clever way to copy in
the second case.
Fix __all__ for compat

Mind blooper is bloopy.
Remove unittest2 from install requirements