Added chain test mock functions and tests. Removed the tester test functions
Data shifting algorithm was wrong. Next time: RTFM before coding...
Tests for chain, several bugfixes and some refactoring to aid testing