Fix similarity unit test on Python 3.