Semilinear updates

This is an update of the PR #1652, with commits simplified to it is easy to see what has been changed.

It fixes some small bugs in the semi-parametric regression and adds unit tests and with data sets for them. See previous closed PR for details.