Xero Interview Question

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