Add assert() to detect failed dynamic allocation memory
Fix unit test