Working version and tests added