; and (2) by inserting after subsection (n) the following new subsection: (o) Special rules for applying nondiscrimination rules To protect older, longer service and grandfathered participants (1) Testing of defined benefit plans with closed classes of participants (A) Benefits, rights, or features provided to closed classes A defined benefit plan which provides benefits, rights, or features to a closed class of participants shall not fail to satisfy the requirements of subsection (a)(4) by reason of the composition of such closed class or the benefits, rights, or features provided to such closed class, if— (i) for the plan year as of which the class closes and the 2 succeeding plan years, such benefits, rights, and features satisfy the requirements of subsection (a)(4) (without regard to this subparagraph but taking into account the rules of subparagraph (I)), (ii) after the date as of which the class was closed, any plan amendment which modifies the closed class or the benefits, rights, and features provided to such closed class does not discriminate significantly in favor of highly compensated employees, and (iii) the class was closed before September 21, 2016, or the plan is described in subparagraph (C). (B) Aggregate testing with defined contribution plans permitted on a benefits basis (i) In general For purposes of determining compliance with subsection (a)(4) and section 410(b), a defined benefit plan described in clause (iii) may be aggregated and tested on a benefits basis with 1 or more defined contribution plans, including with the portion of 1 or more defined contribution plans which— (I) provides matching contributions (as defined in subsection (m)(4)(A)), (II) provides annuity contracts described in section 403(b) which are purchased with matching contributions or nonelective contributions, or (III) consists of an employee stock ownership plan (within the meaning of section 4975(e)(7)) or a tax credit employee stock ownership plan (within the meaning of section 409(a)). (ii) Special rules for