Generalize Git submodule testing

* Use CWD instead of GIT_DIR in test Git commands because in certain
  versions of Git submodule commands will fail when GIT_DIR is set.
* Fix os.listdir() order assumption