I did a reset factory and since I didn't get any answer regarding safety of restoring a backup I didn't restore a backup and spent some time re-installing apps, etc. For anyone who comes to this thread in future I should add that the process was easy. Following this article https://support.apple.com/en-us/HT201274 you don't even need to connect your iPhone to an iTunes. It can reset itself by itself.
It'd be great if I could verify that my device is not under MDM anymore. Until I don't find a way to verify this I'm still a bit upset about it, I'll be happy if I find an official way to verify it's not under MDM anymore.
One more point: the whole process is a bit over complicated, I shouldn't be able to enroll my device to an MDM this easily, there should be more warnings and confirmations and exiting MDM should have an easier way, after all it's my device, I can prove my ownership so it there should be an item in settings letting me quit MDM easily without contacting the IT department of the company, I don't understand why I had to factory reset my device.