CS fixes, minor code changes
Updates tests