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.