Refactor for re-use
Fix completion worker stdout handling on windows