fixed #110 and added unit test