Added test for ssh exec behaviour if the connection is lost. Fixed corresonding bug.