fix some bug and add decode test