Add spec and fix code