refactor unittest bug in postpage view and refactor Post classmethods