[Projects] XRM 29: Clean up the code and add more tests.