tests and code ready for reviewing and merge #163