Yes, wafer-level testing is the first electrical test of the new IC and it's looking for good and bad chips. A bad chip can have either a defect so that it fails, or have timing that is outside of specification. The package can cost more than the die, so it makes sense to test the die before committing to a package.
Assembly can mean that the die is placed inside of a package, and then wires attached to the bonds on the die.
A packaged die may have a new failure, so you need to be 100% certain that all is still well. Also a packaged die may have thermal issues, so testing is paramount. A packaged test is typically more thorough than a wafer-level test.
For memory, CPU or GPU devices the supplier will sell different speed classes. They are all designed be the highest speed, yet due to manufacturing imperfections some of the chips will be slower than others, hence binned to a different speed category. Slower parts also have a lower sales price.
Wafer sorting is the process of testing a die while it's still on the wafer, then "sorting out" what is a good or bad die.
KGD - Known Good Die means that the die passed tests at the wafer level, and is ready for packaging, assembly or direct sale without being packaged. The level of testing depends on what the buyer wants tested.
Package service companies typically offer both package design and test services.
Inputs to an IC have a timing specification called setup and hold time. The amount that they pass the specification is called "margin".
There is ESD - Electro Static Discharge testing, IDDQ (quiescent current) testing, scan testing, Idd current testing, voltage level input testing. There can be testing for alpha particles, Single Event Upset, soft error rate testing, peak current testing, slew rate testing, Vdd voltage testing, pattern sensitivity testing.
Testing depends on the type of design: Digital, Analog, AMS, Memory, CPU, GPU, etc.
There are test engineers (aka product engineers) that spend their lifetime in this area, so it is a very broad topic. The premier test conference is called ITC,
International Test Conference
Device characterization is done by the fab or foundry during process development, and it helps them build the Process Design Kit (PDK) for use by EDA tools.