How to set cursor position in the text editor?
Yep, cursor_set appears to use a mix of 'space_data.top' and 'space_data.visible_lines' and is a might confusing.  However you can use

    bpy.ops.text.jump(line=1)
    bpy.ops.text.move(type='LINE_BEGIN')


Will move the cursor to the beginning of line 1

    bpy.ops.text.jump(line=10)
    bpy.ops.text.move(type='NEXT_WORD')


moves to the first word in in line 10, where you would add a comment #