Add deframify.py tests and fixes for 3.x