fixed overlay bug and added test to verify