fix destroy function through the unittesting