Added a test for a suspicious case.
Fixed a bug that could occur in rare cases.