fix for issue#64, added tests

fix for issue #64, added tests as well.