Tests and patterns improvements