Have been some time since my last post, maybe I'll update now. Have been raining almost every day on July and August so haven't ridden too much. Now on September few better days so have been riding again.
There were still issues even with the new code, so most likely the issues are elsewhere else than code. Sometimes it worked perfectly and something it went full crazy, fluctuating the speed like 60 km/h then a second later 20 km/h and then second later again 45 km/h and so on. I still kept it as is and tried to use it since it sometimes worked. One time then when I was biking with my friends it went crazy again so I made it "stock" by removing the brake disc magnet and adding the rim magnet in place. At least then I could pedal 25 km/h again for the rest of the ride. And actually I kept it like that until this week because I was tired of these problems already.
When I updated the code back in July, it worked fine when testing without any kind of water tight cover, and then I was surpriced that when I sealed it waterproof in my 3D printed cover, display only showed 0 km/h. When I removed the cover, everything worked again without issues. Then I noticed that the cover is so tight that it pushes a resistor to the reset button when the arduino is in the cover

Problem got solved. At least I though so.
Anyways at first ride, everything worked perfectly like mentioned before. But then the crazyness started to happen quite soon. When I made the bike "stock", I though that the issues might be still the 3D printed cover if it pushes the reset button every now and then from vibration or something like that. So this week I removed the printed cover totally and just used plastic bags to make it waterproof (didn't have big enough heat shrinks) to test it out. And again was a lot of fun to drive faster than 25 km/h but then the issues started to happen again. This time it can't be the reset button.
But it seems to work pretty much perfectly if it works fine at the start. Today when I started to ride the bike, it was crazy. Then I shut the bike (and arduino) down two times and started them again, and then it worked without issues. And for the rest of the day it worked without any issues, even when I did shut the bike down few times during the day.
Might be something to do with the arduino itself. Maybe a faulty unit, or I might have broken it somehow when soldering everything in place. Who knows. But if it works by just restarting the bike, I can live with that for now. I have used way too much time on this already, at least for this season which is about to end anyway. At least the summer season...