Fix runtime error on windows
Add test for issue #142