Some refactoring, fixed test execution