Focus most recent window of pid without requiring accessibility approval
This fixes the first quirk but not the second one:

tell application "System Events"
    bundle identifier of process 1 whose id is 1234
end tell
tell application id result
    reopen
    activate
end tell


The same applies to open:

open -a "$(ps -p 1234 -o comm=)"


If there are no open windows, reopen opens a new default window, and if all windows are minimized, reopen unminimizes one window. activate makes the application frontmost.

activate and setting frontmost to true raise all windows but open -a only raises one window.

I thought

lsappinfo launch ASN="$(lsappinfo find pid=1234)"


might also work, but I'm getting a segfault when trying to launch an already running application.