Fix tests to work on Python2