Fix python syntax errors
Fix some pyflakes errors
Remove unused dependency & export
Add haskell tests

Also fix a bug that one of them caught :-)