[refs #200] adds tests for TreeCPD and some improvement in code