Redesigned error handling when connection gets lost - now it will stop all threads and try to reconnect on next call - for #6 and #9
Added test for lost connection and reconnect - for #6 and #9