Fixes and refactorings of tests and main view