bug fix and add testing for python 3