With the truncated triangular distribution, when the Mode of the base triangular distribution was less or equal the truncated minimum of the truncated triangular distribution, then the computed Mean and Variance were incorrect.
For the mean and variance, the integrals should not have been from M to b, but from a to b, e.g. $\int_a^b{... dx}$ instead of $\int_M^b{... dx}$.
This of course changes the numerator for the mean and variance. I noticed this first when for certain parameters the computed variance was negative (which should be impossible). And the simulated variance and mean were nowhere near the computed variance and mean.