fixed lots of warnings that pop up with -DTESTING (make check)

Hi Darshit,

fixed warnings and brushed up these test_*() functions which are compiled with -DTESTING (make check).