tests: fix error handling in test runner
tests: fix error handling in test runner

Currently, the test runner can use variables in the `except` branch
before they're initialized. Hoist all the local state variables to
before the try: to fix that.

Also, make BEFORE_PID logic run only if the test uses `{{BEFORE_PID}}`.

iovisor/bpftrace,iovisor/bpftrace,iovisor/bpftrace,iovisor/bpftrace