Add check tests for socket, fixes for issues found from testing