better referrer handling and tests with ReferrerHandler and dependency control