Update ...DirtiesContextTests to get beans early

Change ContextHierarchyDirtiesContextTests to obtain beans whilst the
ApplicationContext is still open, rather than trying to obtain them
after the context has been closed.