Refactoring of dependencies_for
Test and code for two-level dependency nesting