Make program work in python3; Add tests