Fix Get OMCC Version

Change-Id: Idb67d469acb4311a6e58750b8ede64d044f87ca4
diff --git a/tests/software-upgrades/ONU_Upgrade.robot b/tests/software-upgrades/ONU_Upgrade.robot
index fdf3227..2c1c331 100755
--- a/tests/software-upgrades/ONU_Upgrade.robot
+++ b/tests/software-upgrades/ONU_Upgrade.robot
@@ -723,9 +723,11 @@
 Do ONU Upgrade Compare OMCI Message Version
     [Documentation]    This keyword performs the ONU Upgrade Compare OMCI Message Version test for the first OLT/ONU
     [Arguments]    ${activate_on_success}=${image_activate_on_success}    ${commit_on_success}=${image_commit_on_success}
-    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL'    Remove Adapter Image    ${image_version}    ${onu_device_id}
-    ${firstonu}=      Set Variable    0
-    ${outputfile}=    Set variable    ${OUTPUTDIR}/ONU_SW_Upgrade_Time.txt
+    [Teardown]     Run Keyword If  '${KEYWORD STATUS}'=='FAIL' and '${onu_device_id}'!='${EMPTY}'
+    ...            Remove Adapter Image    ${image_version}    ${onu_device_id}
+    ${onu_device_id}=  Set Variable    ${EMPTY}
+    ${firstonu}=       Set Variable    0
+    ${outputfile}=     Set variable    ${OUTPUTDIR}/ONU_SW_Upgrade_Time.txt
     ${omcc_version}    ${is_omcc_extended}=    Get BBSIM OMCC Version    ${NAMESPACE}
     # Restart BBSIM with OMCI Baseline Message if needed
     Create File    ${outputfile}    This file contains the SW Upgrade download durations