Improve flash messages and added tests