Fixed bugs

the expected counts were not being calculated correctly