Align error codes and handling, fix OTP tests