Python 3, automatic detection of activated environment, tests

Added functionality to automatically detect activated environment and tests to check the old and new functionality.