Refactor 'post' method to unittestable state