Update python test script to work with python3

Fixed some issues with the commits from the last PR.