Fix failing test and python 3 compatibility fix