take available hidden modules into account in dependency resolution

fix for #1061 reported by @ocaisa, including unit test