The test works by calculating the exact probability of obtaining the observed data (and any more extreme) under the null hypothesis that the row and column variables are independent. It uses a hypergeometric distribution to derive this probability. The calculations, while straightforward, can be computationally intensive, which is why software tools are often employed for this purpose.