Fixed flaky test.

When N was small (N < 20000) one test started failing because of rounding errors.
Merge pull request #3491 from pontusmelke/fix-test

Fixed flaky test.