tabletserver: refactored some boilerplate code