SI-8564 + some tests

Here are some basic tests and a fix for [SI-8564](https://issues.scala-lang.org/browse/SI-8564)