Fix bugs in draw_signature and add tests