Solved (more or less). I will leave this here in case anyone has a similar problem.
The behaviour was caused by jupyter notebook, I cannot really determine what exactly was the problem, I cleared all variables carefully, but in proper IDEs this behaviour does not occur, so I guess it is some JN thing where something is not cleared out properly to increase efficiency if I reuse it.