Fix some issues and update tests

subj