Fix usage of range in tests for python 3