Refactor handleConsoleMessage()
(preparation for #17)