Added support for hidden apps (bug 1019249, 1019251)

I couldn't read the tests because they were too long. I wouldn't expect anyone else to read them nor understand them they way they are right now.