I don't know much about much, but this looks like a lot of duplicated code in the previous functions. Not sure if it's worth refactoring out into a separate function (but on the other hand its just tests).