Do not leak subproject remotes
Description
When initialising remote caches, we should make a copy of the global list rather than using the global list.
This has actually been fixed twice before: e1420437 and 1ee4a4ba.
I've added some asserts to the test so hopefully this won't happen again in the future.
I've also done some cleanup of tests/artifact/junctions.py
so that it reads better and I've moved some functions to testutils as to avoid duplicate code.