Fix Python tests, add Python 3 support