add test and refactor dependencies
able to resolve nested dependencies properly