Add test to make sure weird boundary cases don't cause infinite loop.

Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>