test: Move test running into a separate function