some function renaming and tests added