Move caching of requirements to helper function and add unit tests.
Merge pull request #4900 from OddBloke/multi_pip_requirements

Move caching of requirements to helper function and add unit tests.