refactor tests and implementation with cs