Refactor  tests and RUI