Fix tests to work in both default and gadget mode.
Add forgotten changes from previous commits.