Seperated layer processing from controller, refactored tests around layer writer to work with new contructor and in new class