Refactoring TimelineRepository.java and added a unit test for it