Bank of America Corp.’s Countrywide unit has agreed to pay $500 million to settle a class action lawsuit over billions of dollars in residential mortgage-backed securities that were downgraded to junk, Bloomberg News reports.