Add documentation, tests and fix CS