Misc tests, fixes, style