Twist of magnetic fields in solar active regions