Refactoring and fixed test runner