updated writeup and added test codes