added tests, revised with samuel, xiaoying