adapters/adapter: split plugin instantiation logic into separate function, tests