added tests, refactored views