Added ztask_packet and fixes memory leaks in selftest