[#642] Inject `error_handler` instead of explicitly passing it as an argument, split large test into smaller tests