fix tests and add a little safety to logging