Excercise more mqtt code and fix memory leak in unit test