Added Tcp Auto tests

Also fix a problem on Tcp send found by running auto tests. I think the problem also affects Udp. I will do a similar fix after this review.