Fix behaviour on Python 2.x, and fix mistake on tests can didn't expose the problem