Fix CalculateFactorialChainLength, and improve tests for it.