fixed issue #6 and wrote passing test