Listeners for state changes are now cleaned up

Fixed deprecated warnings in tests