Removed compiled patterns

They are cached internally anyway.
Removed unnecessary import
Added mocking
Removed unused method
Modified tests

Non-mock format_link_reference_definitions tests were changed to be
_format_links tests. Many were removed since they were no longer
relevant.