Refactor cases in codegen tests