fix and test premature copas socket:close