Fix issue #3 and add test file for issue #4