Refactor permuted backtrace test allocation.

Refactor permuted backtrace test allocation that was originally used
only by the prof_accum test, so that it can be used by other heap
profiling test binaries.
Test prof.reset mallctl and fix numerous discovered bugs.