Trace-Based Code Generation for Model-Based Testing