Break early if original test passes and move declarations outside of loop