Fixes #164, with test-case, as requested by Julian Berman.