better fix for #15 (with a test case now)