Bug 1678

Tests: 
https://gist.github.com/anonymous/e02c2bde34b459d88546