refactor: Simplify compilation result tests by factoring out common code.