Fix edge-case. Add test for it