Check out the modular multiplicative inverse. This is the equivalent of division modulo some number. Implementing it using the EEA can be tricky, though there is a shortcut.
Also, as Frob says, you have the wrong decryption function. You're trying to get "x" back, not "a". Look through it again.
Also, for bonus points, implement a message decryption function without using "a" nor "b". ![]()