Refactoring done and test fixed.