modules: mqtt: misc refactoring and fix of mqtt-destroy