Fix coefficients calculation * test for regression * detailed comments what is going on prevent setting the `k[-1]` item * more readable