Fix logic of ssh detection.
fix #186
integrated issues into unit tests and addressed #169
added missing includes for tests