core: fix condition on script callback number done inside EXTRA_DEBUG

- reported by Seudin Kasumovic, FS#388

(cherry picked from commit 740d407be4e35ee945658365ae38a1bba30fafc7)
htable: fix crash if key_value is not string
(cherry picked from commit 065439c0fbabe2806fcd615cec5e2445db59beec)
dmq: fixed crash caused by freeing pointer too early on tm callback
(cherry picked from commit 8be7de6d1d383c2e0e476e739a6b3fa5101bac12)
modules/utils: fixed memory leak and possible crash

- patch against 4.0 was provided by Guillaume Bour
(cherry picked from commit 92b947059dbde8ada3c757d7e6af48d79f9e7e12)