fix test failures in Python 2.5 and 3.1