Refactored socket tests