Fix alloc/dealloc mismatch in writer tests