It's measuring performance from the router to the test server end to end which is intentional.
Measuring the access layer link performance is easy, it's already done by the kit either side, and meaningless to customer experience. It sets an upper bound only.
The TCP stacks aren't random. One side is controlled by whomever is administrating the tests, the other by the provider of the CPE, so it's a known environment.
The point of having the software running on the router is to remove the end user's local network, including software, from the equation. More reliable than having the end user send in speed tests carried out on their own machines.