Fix generate contract bug + create more meaningfull exceptionmessage