add testcases
bugfix
Python 2 conpatible