Refactor Options logic

This moves the options logic out of the main file and unit tests it.