Fixed flaky tests. (Closes #408 for now.)