Simplified view code and added some tests.