SI-8564 + some tests

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