Add test and make it a final version for thesis