Fix up AMD module ID calculation

Simplify the calculation of AMD loader IDs, and finding paths to where to load other modules from. In particular, remove hard coded base paths.

We use a flatter hierarchy for AMD modules.

All of this means that we can be less repetitious, but more importantly it can make tests work much easier than before.