Adding tests for PostRepository and PostService, including some refactoring