It does need to remove *consecutive* cdf=0 points, since those can't be fixed by small tweaks like the one you described.  Anyway I reverted to an old version of this flat-cdf checker, which I replaced when it didn't work with integ1d as I was implementing it (integrating from 0 every time), slightly updated to work properly.  I now pass all unit tests, and I also get the right answers for both a square wave and a sawtooth.  I will note that the tweaking of the probability to avoid dcdf=0 regions seems to create a very slight negative bias, in the sense that the mean value of a million calls is always slightly below the expected value rather than above, but it's always within sqrt(N) of the right value.