tests rewritten and extended, pattern matching bugs fixed, broadcasts added