Support py3 and add tests