There's a lot of duplicate code between this and the previous test. Can any of it be factored out to a helper method?