Pergunta de entrevista da empresa Xero

How could this code be restructured? Where would you want unit test coverage? etc