Fixes issue #8, added test