Go to System Preferences > Users & Groups. Then create a new administrator account for testing. Then logout from Apple menu and login to new account you created (it will be blank, it is only for testing). Does the fan goes to full speed in this account ?
Also, do these steps.
Shut down thec omputer.
Plug in the power adapter to a power source, connecting it to the Mac if not already connected.
On the keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
Release all the keys and the power button at the same time.
Press the power button to turn on the computer.
Then follow the steps below;
Shut down your Mac
Restart and immediately hold down Command-Option-P-R keys at the same time
Hold the keys down until the computer restarts and you hear the startup sound for two or three times.
Release the keys and let the Mac boot up.