Created a test for close() and waking up threads, fixed related socket code slightly