Adding another error code to the logic that makes us conclude a device connection is dead.

BugzID:3339
Changing some variable names, exporting a helper function.