LOGSTASH-1824 Fix the TCP input so it passes unit tests and does not drop messages

Unit tests were failing and now pass.

Please note that there was one unit test regarding latin-1 to UTF-8 conversion that did not work correctly for me.
I am not sure if I marked correctly as being broken.