[base] Array dealloc clean up.

Check that array pointers are not null before
deleting.

Set array pointers to null after delete.
[tests] Fix bug in peak detection tests.