Added tests and code to address #152
Also PEP8ery
Merge branch 't152' Adds better handling of state logs going back and forth Fixes #152