Rebased and updated tests.