rewritten parts of ut

bug fixes