fixed ticket #660 and tested case for that