did some refactoring and improved the test script