Fix some minor issues, fix some unit tests