Adapt test script for py3k compatibility