Fix some problems with tests in python2.