Added locking functions and tests
Added signal handler for client and server