maintenance mode is now working
refactoring
added some test cases