Added random bug fixes and created a small test