Chi Squared by contingency table. Refactoring