Fix tests with some versions of Python 2