how to set a webform field value in my custom module
Ok, try not to confuse Webform module stuff with core drupal FAPI stuff.

You cannot set $form['submitted']['test_id']['#value'] = 'COURSE_ID-123456'; in the form_alter because $form is not passed in by reference and the submitted key values is set after the form is POSTed to my knowledge.

So you're trying to put stuff into the form in the wrong time and place. If I was just using FAPI and not webform. I would not use a "hidden" form value (which isnt really hidden on the page), but use Form build_args or $form_state['MYMODULE_temporary'] to hold my custom course_id in the FAPI form lifecycle so that the client never sees these values, but they are passed along through form validation and submission.

You can probably do the same technique I describe above and then implement hook_webform_submission_insert(), or hook_webform_submission_update() (if your form supports Drafts) to perform submission logic and look at your custom course_id stuff ...