extract method from anonymous class for testing