Added a testcase for #158 and fixed #158.