Checkout should not recreate deleted files - with fix

This contains @ethomson's failing test that checkout was incorrectly recreating a deleted file even in SAFE checkout mode, plus it has the fix for the problem and some extra new checkout test helpers that make it easier to look at exactly what checkout is doing.