The legislation, which passed a key test in the state Senate on Wednesday, is the product of a compromise between consumer advocates and some lenders.