Merge "Rewrite tests and add tests that demonstrate a bug"