More tests, tweaks and fixes