Check for unpublished/archived categories when flag is set

A check for bad categories should only be done when the publishing flag is set, otherwise it is not possible to gen an unpublished or archived category with the following code:

$categories = JCategories::getInstance('Foo', array(
	'access' => false,
	'published' => false
));
$category = $categories->get((int) $catid);