[MGM] Better socket handling on test

Change-Id: I118e14baa28f66a7f725beec2927d58f28b77736