fixed and tested computation of coefficients