Organized Javascript, added framework for testing