added some application tests and refactored some code based on that