test refactoring

@umop, moved test common code into a new library, Also, some library name and `final` nits.