Fixed bug with password prompt, added tests

Fixes: bug #1131237

Change-Id: Ifcd9543ed5ac9526e32025ff3acd51d36b27a224