Refactor code across multiple files while respecting dependencies and updating related tests.
