Integration tests for handoff - fixes 406

Fixes #406 (not #396 as the branch name claims). Some code I ended up writing unnecessarily but which is useful.