Add tests that would have caught the bug I found randomly during code review