fix wraparound logic, add tests to fail cases and comments to clarify conventions of fundamental domains