Added testing and updated code for testing