Some fixes in the example

Implemented some fixes, and tests for the scaling algorithm.