fixing two core test cases on windows + some refactoring