Pyapi

More tests, a bug fix