Fix bugs on partial mapping, and some were tested