clean up tests and make them print useful messages when they fail.
make tests attempt to print somewhat-useful state diffs on failure
Fix #264: replacement movement layer masks were using the wrong index variable.