Vanchi/radar117 closed socket fix again

@samshull We need more unit tests around the state manager's behaviour I think. (Though my test for this scenario can't be helped to be not convoluted).