Make tools work on Py3, and added working tests.