Strange behaviour of toSet