added some tests and some py3 compatibility