[cmake,bugfix] Fixes traversal of subdirs for make all.

Previously, if test was not the last entry in the list of subdirectories
then all subdirectories that were listed after test were con processed
during all and install. This patch fixes this behaviour.
[cmake,bugfix] Fixes requiredness of module

Previously, dependencies were not correctly searched for as
required packages. This patch fixes this.