I'm afraid that what I wrote doesn't fix the bug entirely. I have a map 20 tiles long (tiles are 16x16) and the last 2 tiles are somehow non collidable. If I change the resolution to a bigger value the bug doesn't happen.
I'll see if today can fix it, if not I'll end up switching engine :\