add settings spec and fix some bug.