Fix reset_after_eunit function to stop applications that were loaded during the test runs.

The original implementation used a list comprehension to account for the applications to be stopped,
but the code didn't work as expected leaving applications still running. These applications would later be
killed by the kill_extras function resulting in errors. This fix computes the applications that
must be stopped/unloaded using a digraph of dependencies. I noticed the problem while trying to run eunit tests from lager as a dependency of a project of mine: https://github.com/basho/lager/issues/181. After digging into the problem I came up with the proposed solution. The only thing I'm not sure about is the need to call  reconstruct_app_env_vars(Apps). I started to think that we should actually call reconstruct_app_env_vars(OldApps), but I leave the question open for the gurus.