Refactor a bunch of our test helpers to make them more flexible

This also changes most of them use unique IDs for the DB entries they create,
meaning they can now be called multiple times in a single test.

My next branch will get rid of some duplication by reusing those more
flexible functions. This is just the first step