fix #35 and add regression test