Finalizes implementation and adds testcases