I added helper methods for use in the PR, and added tests for them (along with these tests). I later realised I don't need the helpers methods, but thought I may as well leave these tests here, even though its not really relevant to the PR.