Set referencemethod in state pattern. Improved isDone method with callback from XHR.