Correct comment
Add tests and fix some issues

Tests taken from #6360