Clean up tests to use TypedRefGuard instead of the mess we had before