tests: add option to stop on first error
refactor and move more logic into the backends