Test and misc fixes