rearranged apt-cache check to run before installation and include test dependencies to be checked