Rework the classpath scanning and caching logic.

- it now actually works (caching for directories was broken)
- remove most of the regex class <-> file name replacements
- add debugging
Scan the right paths for test and runtime.
Add a couple of integration tests for test and compile scope.