Some clean-up and more thorough tests