fixed#431 with tests