Refactored and added tests to messy railitie configuration