Fix a minor bug in getDeviceForDeviceID() and getMessageForDeviceID()