Proposal for fix.
Added some unit tests. Case 1 now verified.