Adding refactorings. WIP.
Refactoring: extract function with equality checking
Small fix in refactorings
Merge branch 'refactoring'