Pull a bunch of stuff out from the specific stubs class so it can be
reused.