Added some tests and Py3K compatibility fixes