Cleaned up a bit and added some application tests