Fixing unit test fail, and refactor to make them compatible with windows