To detect whether my phone is jailbroken or not?
I think the most simple test is to see if the cydia app is installed.

But that app can sometimes be hidden.

So you could scroll all the way to the left to spotlight search, type in "cydia" if the app comes up, then its jailbroken.

But It could be that the spotlight feature is disabled. In this case your device is jailbroken as well.

Technically I think it would be possible to hide the cydia app even from the spotlight search. But I don't see in any point in doing this. So I think checking for the cydia app is pretty watertight.