Refactor task handling to setup a Balsa context