Refactored and cleaned up tests, modified to make them more reliable when executed from within Java environments.