Avoid undefined beahvior in test code

Change-Id: I721785a56c9adb2781c4afe14ed2a9e7254acab8