Rebase on master, bug fixes, more self tests

[ci skip]