Fix broken async tests.
Implement safe flags for socket operations.