fix contingency table calcs, add tests