Refactored posts and replies and added tests