Media magnate Nabil Karoui’s run for president was testing the rules of Tunisia’s young democracy even before he was put in custody last month charged with tax fraud and money laundering.