Improved Main.java and Test.java for testing the locks