decompose prefetching and add unit tests
testing, clean up and refactor

communjs can not handle the data-main and config referencing non
absolute paths. They are resolved before fetching and the base path
is used internally. Also include general clean up and refactor mostly
to do with preloading of scripts
Remove odd case in require and fix incorrect tests