Listeners for state changes are now cleaned up

Fixed deprecated warnings in tests
Merge pull request #28 from damienlevin/master

Listeners for state changes are now cleaned up