Fixing wrong handling of server socket SHDP-138

Should fix the tests and there was an actual bug outside of tests which caused problems. Two new tests for better testing. Previous commit disabling some testing code in master should be reverted.