Refactored plugins loader and wrote tests