These patches are the result of trying to get a bit more familiar with the PulseAudio code. As a start, I added a few unit tests for code in core-util.c, and doing so I noticed a small glitch in pa_replace(), which I fixed in the last of the three commits. Please review (and perhaps apply) these changes. Cheers! Uli