Working copy (final) 

with tests and expected results