Implement tests and refactor configuration managment