test-lib: Make the test_external_* functions TAP-aware