Extracts some methods to make testing easier.