sets socket timeout in Server
fixed tests
refactored code