Add doctests to test suite; make work on Python 3