End To End tests not working...more experiments needed.
Finally consistently working test
Minor refactoring done.