fixed and added test for issue #2