pattern.metrics unit tests + small bug fixes