Remove obsolete <malloc.h> and provide plain-jane BSD makefile for tests
Beefed up test makefile; almost resolved the qsort_r saga.