Fixed issue #3169 (+ test cases)