Studying the other `grub-*` commands one at a time...
`grub-fstest` performs some OS-specific initialization, allocates some memory, parses commandline flags, inits various GRUB subsystems, possibly sets $debug envvar, sets $root in one of 2 ways, invokes a core routine, & cleans up. Which in turn iterates over all known disks running `loopback` to each, possibly runs `cryptomount`, (de)inits various subsystems, branches over the given subcommand, & invokes `loopback` again for all disks.
1/2?
The `ls`, `zfsinfo`, `blocklist`, `testload`, & (with more argument-reformatting) `xnu_uuid` commands invokes corresponding builtin GRUB commands. The `cp` command carefully opens a target file, & invokes a 2-codepath helper to carefully read the given file or stdin in chunks passing each to a callback which in this case writes each chunk to the target file. `cat` invokes the same helper writing each chunk to stdout.
2/3?