Attempt to fix #88, changing way how long messages handled

This is working version of the fix.
This seems to introduce a new bug. There is now a trailing empty message when the connection is closed. This is because Send() is called even if ok == false