Tidy up code and tests post-rebase