fix error in wrapping calculation in chisq. Fixes #19, possibly #16