[PATCH] tests: avoid close of bad file handle in commandtest