qa: Move more code into libqa

This is where it should be.