DistributedStateManager fixes and added unit test.