Added tests and refactored winrm fix