Added state handler
Added JUNIT test