Test stub improvements

Remaining improvements for #504