I think you only implemented equation (2) from the link you posted. If you read what's written on that page after equation (2), you will find this:
"Now find all possible matrices of nonnegative integers consistent with the row and column sums Ri and Cj. For each one, calculate the associated conditional probability using (2), where the sum of these probabilities must be 1.
To compute the P-value of the test, the tables must then be ordered by some criterion that measures dependence, and those tables that represent equal or greater deviation from independence than the observed table are the ones whose probabilities are added together."
06 Apr 2011
MyFisher23
A very compact routine for Fisher's exact test on 2x3 contingency table
Author: Giuseppe Cardillo
This doesn't correctly compute a fisher exact test p-value. It only computes the probability of exactly getting the observed contingency table. To compute a p-value, one must compute the probability of obtaining the observed results *OR SOMETHING MORE EXTREME*. In this case, one has to sum the probabilities over all possible "More extreme" contingency tables; this sum is the value of the Fisher Exact Test.