Add test and some changes.
Final fixes.