Fix several tests for Python 3