refactor test and fix long-lived bug for windows