Updated tests
Reimplemented inner algorithms