Fix regression and tests