tests: make tests.sh more robust

Signed-off-by: Jean Privat <jean@pryen.org>