Repeating tests pass.

Seemed to have moved a lot of code around in the file, which makes the
diff quite messy. Sorry 'bout that.