fixing some code to be compatible with python 3.3 and update the tests.