Fixed bugs executing remote commands

Change-Id: I5c94aff0c055ab65776e9da123b47d29a8eb6d71