Refactor to move mocking close to where it's used

Moved the mocking of put_artefact! and create_artefact! to the setup
blocks relevant to the particular tests which rely on them. This makes
the tests easier to understand because the assertions which rely on
those setup steps are close to the setup steps themselves, so you can
follow the entire thread of the test in one screenful of code.
Bugfix in test