adding tests and refactor
Merge pull request #1 from kienpham2000/post

adding tests and refactor