fix test bug and minor cleanup