Fix refactoring bugs
Fix #18 and add specs for Application removing.