How would you test the battery?
sounds fraught with issues to me - like buying a second-hand phone or tablet.
Must admit I know nowt about the second hand ebike market - don't yet have one.
Battery health can be measured on a test bench with the correct equipment.
Although rather like an MoT, it can only tell you the state of play at the time of the test.
The unknown factor being rate of decline - some batteries fall off a cliff when they do start to lose charge.
There's a good chance a battery in good health will last another year, which is the length of the warranty.
It's also fair to say battery service life is getting longer, although progress is at a glacial pace.