fix issue #481 and add spec for it. Closes #481