Refactoring and adding tests for Analyser