test: should use while not if in send_expect

The previous version of `send_expect` function always
tests the list[0], then this is the reason why #7748
might not be detected by `make test`.

/cc @indutny