Improve detection if called directly or required as a module

The original method brakes if we use a symlink to point to the repo. This method does not depend on an external system paths.