fixed ticket #660 and test case for that