Fixes #664. This makes sure that python code is actually correct
Fixed a perl test while I was there
Merge pull request #665 from alexkalderimis/664-python-code-gen

664 python code gen