Failing test and fix for running take_over twice.

When user manages to run `take_over` twice with the same arguments,
`tak_over` creates an orphan. Fixes #617.

Update: Ready to review & merge. Required database update is included in branch.sql (deleting the orphans).