added test, and little fix on CS