Refactor code that creates plugin object from test name into one function.