Add attempts parameter, add doctoring, clean the code
First tests for Bernard checks

Fix corresponding issues