[PATCH v2 37/43] test: Improve handling of sending commands