use pattern matching in function definitions to avoid useless "let...in"
restructuring tests too