Added unit-tests for hierarchical algorithm