cmp_mem() improvements

- NULL for got and expected is handled
- reworked logic so memcmp() is not needed
- cosmetic fix in diagnostics