Tests and fixes

This adds tests for the python code and fixes #1 and #2