Wal-Mart to pay $40 million to workers in class-action lawsuit