Fixed tests and improved test flow