Fixed all warnings from tests.
Removed wrong call to zfree that caused a segfault.
Using zstrndup instead of strndup)
Implemented zstrndup.
Guarding against freeing NULL pointers.
More guarding against freeing NULL pointers.