Fix free() and add some missing functions like N() etc
Update test cases to include free()